I have a dataset with US counties where for each county in each quarter I have the type of industrial sectors "Industry", number of establishments per industry"estab_byindustry", number of estabs as percentage of the total (estab_percent_ind) and a score per industry "Ext_dip". I want to assign a dummy to each county which takes value 1 if more than 50% of the establishments in the county (for each quarter) belong to industries that have a score which is higher than the median of Ext_dip (around 0.43), and zero otherwise. The score is time invariant, the same industry in different years is assigned the same score.
Thank you for your help,
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long fips int Year byte quarter str41 Industry long estab_byindustry float estab_percent_ind double Ext_dip 1001 1994 1 "Natural resources and mining" 27 .04299363 .44 1001 1994 1 "Construction" 99 .1576433 .35 1001 1994 1 "Manufacturing" 37 .0589172 .47 1001 1994 1 "Trade, transportation, and utilities" 175 .2786624 .52 1001 1994 1 "Information" 8 .012738854 .34 1001 1994 1 "Financial activities" 56 .08917198 .53 1001 1994 1 "Professional and business services" 59 .09394904 .58 1001 1994 1 "Education and health services" 49 .07802548 .39 1001 1994 1 "Leisure and hospitality" 43 .068471335 .42 1001 1994 1 "Other services" 74 .1178344 .48 1001 1994 2 "Natural resources and mining" 26 .0416 .44 1001 1994 2 "Construction" 101 .1616 .35 1001 1994 2 "Manufacturing" 37 .0592 .47 1001 1994 2 "Trade, transportation, and utilities" 171 .2736 .52 1001 1994 2 "Information" 8 .0128 .34 1001 1994 2 "Financial activities" 56 .0896 .53 1001 1994 2 "Professional and business services" 57 .0912 .58 1001 1994 2 "Education and health services" 49 .0784 .39 1001 1994 2 "Leisure and hospitality" 43 .0688 .42 1001 1994 2 "Other services" 76 .1216 .48 1001 1994 3 "Natural resources and mining" 25 .03987241 .44 1001 1994 3 "Construction" 99 .15789473 .35 1001 1994 3 "Manufacturing" 37 .05901117 .47 1001 1994 3 "Trade, transportation, and utilities" 173 .27591705 .52 1001 1994 3 "Information" 8 .01275917 .34 1001 1994 3 "Financial activities" 56 .0893142 .53 1001 1994 3 "Professional and business services" 60 .09569378 .58 1001 1994 3 "Education and health services" 49 .07814992 .39 1001 1994 3 "Leisure and hospitality" 43 .068580545 .42 1001 1994 3 "Other services" 76 .12121212 .48 1001 1994 4 "Natural resources and mining" 26 .03957382 .44 1001 1994 4 "Construction" 101 .15372907 .35 1001 1994 4 "Manufacturing" 37 .05631659 .47 1001 1994 4 "Trade, transportation, and utilities" 174 .2648402 .52 1001 1994 4 "Information" 8 .01217656 .34 1001 1994 4 "Financial activities" 79 .12024353 .53 1001 1994 4 "Professional and business services" 64 .09741248 .58 1001 1994 4 "Education and health services" 48 .07305936 .39 1001 1994 4 "Leisure and hospitality" 44 .06697108 .42 1001 1994 4 "Other services" 75 .11415525 .48 1001 1995 1 "Natural resources and mining" 28 .04395605 .44 1001 1995 1 "Construction" 104 .1632653 .35 1001 1995 1 "Manufacturing" 35 .05494506 .47 1001 1995 1 "Trade, transportation, and utilities" 174 .27315542 .52 1001 1995 1 "Information" 8 .01255887 .34 1001 1995 1 "Financial activities" 62 .09733124 .53 1001 1995 1 "Professional and business services" 64 .10047096 .58 1001 1995 1 "Education and health services" 45 .07064364 .39 1001 1995 1 "Leisure and hospitality" 45 .07064364 .42 1001 1995 1 "Other services" 71 .11145997 .48 6031 1996 1 "Natural resources and mining" 547 .2058713 .44 6031 1996 1 "Construction" 153 .05758374 .35 6031 1996 1 "Manufacturing" 75 .028227324 .47 6031 1996 1 "Trade, transportation, and utilities" 465 .1750094 .52 6031 1996 1 "Information" 23 .00865638 .34 6031 1996 1 "Financial activities" 155 .05833647 .53 6031 1996 1 "Professional and business services" 162 .06097102 .58 6031 1996 1 "Education and health services" 175 .06586376 .39 6031 1996 1 "Leisure and hospitality" 166 .06247648 .42 6031 1996 1 "Other services" 735 .27662778 .48 6031 1996 2 "Natural resources and mining" 524 .2137903 .44 6031 1996 2 "Construction" 143 .05834353 .35 6031 1996 2 "Manufacturing" 75 .030599754 .47 6031 1996 2 "Trade, transportation, and utilities" 447 .18237454 .52 6031 1996 2 "Information" 19 .007751938 .34 6031 1996 2 "Financial activities" 150 .06119951 .53 6031 1996 2 "Professional and business services" 157 .06405549 .58 6031 1996 2 "Education and health services" 167 .068135455 .39 6031 1996 2 "Leisure and hospitality" 159 .06487148 .42 6031 1996 2 "Other services" 610 .248878 .48 6031 1996 3 "Natural resources and mining" 523 .20995584 .44 6031 1996 3 "Construction" 147 .05901245 .35 6031 1996 3 "Manufacturing" 76 .030509835 .47 6031 1996 3 "Trade, transportation, and utilities" 448 .17984745 .52 6031 1996 3 "Information" 19 .007627459 .34 6031 1996 3 "Financial activities" 144 .05780811 .53 6031 1996 3 "Professional and business services" 153 .06142111 .58 6031 1996 3 "Education and health services" 167 .06704135 .39 6031 1996 3 "Leisure and hospitality" 161 .06463268 .42 6031 1996 3 "Other services" 653 .26214373 .48 6031 1996 4 "Natural resources and mining" 495 .2030353 .44 6031 1996 4 "Construction" 146 .05988515 .35 6031 1996 4 "Manufacturing" 70 .02871206 .47 6031 1996 4 "Trade, transportation, and utilities" 435 .17842494 .52 6031 1996 4 "Information" 18 .0073831 .34 6031 1996 4 "Financial activities" 140 .05742412 .53 6031 1996 4 "Professional and business services" 142 .05824446 .58 6031 1996 4 "Education and health services" 160 .06562756 .39 6031 1996 4 "Leisure and hospitality" 152 .06234619 .42 6031 1996 4 "Other services" 680 .27891713 .48 end
0 Response to Assign a dummy 0/1 to each county based on a score
Post a Comment