Due to certain nature of my master data, I need to hard code my using data ( the following one ) from city and state name to countyfip code.
My using data has all three required variables of all the cities , states and counties of USA. On Mac, if you hold down the option button ( in windows you hold down alt button ) and move the cursor it lets you do multiple lines of coding simultaneously if all the variables are aligned like the attached picture of my gen county and city name. But, whenever I'm doing the state this particular thing is not aligned.
If I could make the state_id aligned vertically , then I can easily code manually ( 100 ore more observations just typing once ) . Is there anything I could do on the do file to align the state_id vertically so that I can apply the same method ? I'm attaching picture and picture both so that you have a better grasp of what I'm talking about. As you can see in my data and picture that the bottom half needs be coded simultaneously to change it from bottom half format to top half format. The problem arises, I cannot do it simultaneously , since the statefip is not vertically aligned. But, county and city are vertically aligned , so I can apply the method in those variables.
My using data has all three required variables of all the cities , states and counties of USA. On Mac, if you hold down the option button ( in windows you hold down alt button ) and move the cursor it lets you do multiple lines of coding simultaneously if all the variables are aligned like the attached picture of my gen county and city name. But, whenever I'm doing the state this particular thing is not aligned.
If I could make the state_id aligned vertically , then I can easily code manually ( 100 ore more observations just typing once ) . Is there anything I could do on the do file to align the state_id vertically so that I can apply the same method ? I'm attaching picture and picture both so that you have a better grasp of what I'm talking about. As you can see in my data and picture that the bottom half needs be coded simultaneously to change it from bottom half format to top half format. The problem arises, I cannot do it simultaneously , since the statefip is not vertically aligned. But, county and city are vertically aligned , so I can apply the method in those variables.
Code:
gen county = 41051 if city == "Portland" & statefip =="OR" gen county = 48029 if city == "San Antonio" & statefip == "TX" gen county = 29510 if city == "St. Louis" & statefip =="MO" gen county = 6067 if city == "Sacramento" & statefip =="CA" gen county = 12095 if city == "Orlando" & statefip == "FL" gen county = 6085 if city == "San Jose" & statefip =="CA" gen county = 39035 if city == "Cleveland" & statefip =="OH" gen county = 42003 if city == "Pittsburgh" & statefip =="PA" gen county = 48453 if city == "Austin TX" & statefip =="TX" gen county = 39061 if city == "Cincinnati" & statefip =="OH" gen county = 29095 if city == "Kansas City" & statefip =="MO" gen county = 36061 if city == "Manhattan" & statefip =="NY" gen county = 18097 if city == "Indianapolis" & statefip =="IN" gen county = 39049 if city == "Columbus" & statefip =="OH" gen county = 37119 if city == "Charlotte" & statefip =="NC" 5119 Little Rock AR 6001 Oakland CA 37063 Durham NC 37067 Winston-Salem NC 12071 Bonita Springs FL 6065 Indio CA 12035 Palm Coast FL 47065 Chattanooga TN 53063 Spokane WA 36067 Syracuse NY 42071 Lancaster PA 48439 Arlington TX 6077 Stockton CA 36027 Poughkeepsie NY 13245 Augusta GA 16001 Boise ID 6111 Oxnard CA 42069 Scranton PA 6099 Modesto CA 12097 Kissimmee FL 8001 Aurora CO 39099 Youngstown OH 5143 Fayetteville AR
Comment