Hello,
I am trying to generate a variable that indicates if more than 1/3 of the population (perc_pop_block) in a census tract (geo_id) is at least 1 mile away from a clinic (mile_1). The distance is measured at the block group level (block_group) and block groups are nested within census tracts. I can easily code this variable for tracts where one or more block groups is a mile away from a clinic
but I also need to be able to create this variable for tracts for which several block groups equal more than 33% of population being further than 1 mile from a clinic. The data below represents an example for a tract in which more than 33% of the population is away from a clinic but no one block group represents more than 33%.
I'd appreciate any help. Thank you.
I am trying to generate a variable that indicates if more than 1/3 of the population (perc_pop_block) in a census tract (geo_id) is at least 1 mile away from a clinic (mile_1). The distance is measured at the block group level (block_group) and block groups are nested within census tracts. I can easily code this variable for tracts where one or more block groups is a mile away from a clinic
Code:
gen mile_33=1 if mile_1==1 & perc_pop_block>(1/3)
I'd appreciate any help. Thank you.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str12 geo_id byte block_group float near_distance int(pop_block tract_pop) byte mile_1 float perc_pop_block "A29189210600" 1 .8881201 1336 6425 0 .20793775 "A29189210600" 2 1.3657404 1443 6425 1 .22459143 "A29189210600" 3 1.742405 711 6425 1 .11066148 "A29189210600" 4 1.1704314 1260 6425 1 .19610895 "A29189210600" 5 .7445323 1675 6425 0 .26070037 end