I need to merge master data (which is repeated cross section data - observations of couple of variables for each county at 4 different quarter for a particular year) with repeated cross section of my using data. The format for my using data is given here :
My master data is like the following
I figure that I need to create the number of population for each age group, race and gender in a wide format for each year and a county so that I can easily merge all the different age group , race , gender population with my master data merging on the variable of year and county.
Can anyone kindly tell me how I can create the wide format of my using data for variables age, race , gender , hispanic on the basis of pop value ( the number of population for those categories in those counties for that particular year).
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int year float county byte(race hispanic gender) float(age pop) 1990 1001 1 0 1 5 882 1990 1001 1 0 1 6 1059 1990 1001 1 0 1 7 1148 1990 1001 1 0 1 8 1059 1990 1001 1 0 1 9 1051 1990 1001 1 0 1 10 876 1990 1001 1 0 1 11 792 1990 1001 1 0 1 12 670 1990 1001 1 0 1 13 519 1990 1001 1 0 2 5 824 1990 1001 1 0 2 6 1096 1990 1001 1 0 2 7 1199 1990 1001 1 0 2 8 1105 1990 1001 1 0 2 9 1093 1990 1001 1 0 2 10 886 1990 1001 1 0 2 11 814 1990 1001 1 0 2 12 671 1990 1001 1 0 2 13 541 1990 1001 1 1 1 5 4 1990 1001 1 1 1 6 6 1990 1001 1 1 1 7 10 1990 1001 1 1 1 8 8 1990 1001 1 1 1 9 5 1990 1001 1 1 1 10 4 1990 1001 1 1 1 11 3 1990 1001 1 1 1 12 4 1990 1001 1 1 1 13 4 1990 1001 1 1 2 5 4 1990 1001 1 1 2 6 7 1990 1001 1 1 2 7 11 1990 1001 4 0 2 9 5 1990 1001 4 0 2 10 7 1990 1001 4 0 2 11 14 1990 1001 4 0 2 12 9 1990 1001 4 0 2 13 6 1990 1001 4 1 2 7 1 1990 1003 1 0 1 5 2308 1990 1003 1 0 1 6 2822 1990 1003 1 0 1 7 3148 1990 1003 1 0 1 8 3128 1990 1003 1 0 1 9 3146 end label values race race label def race 1 "White", modify label def race 2 "Black", modify label def race 3 "American Indian/Alaska Native (1990+)", modify label def race 4 "Asian or Pacific Islander (1990+)", modify label values hispanic hispanic label def hispanic 0 "Non-Hispanic", modify label def hispanic 1 "Hispanic", modify label values gender sex label def sex 1 "Male", modify label def sex 2 "Female", modify label values age age label def age 5 "20-24 years", modify label def age 6 "25-29 years", modify label def age 7 "30-34 years", modify label def age 8 "35-39 years", modify label def age 9 "40-44 years", modify label def age 10 "45-49 years", modify label def age 11 "50-54 years", modify label def age 12 "55-59 years", modify label def age 13 "60-64 years", modify
My master data is like the following
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int year byte qtr str5 county str6 industry_code long avg_wkly_wage 2000 1 "01000" "10" 555 2000 2 "01000" "10" 545 2000 3 "01000" "10" 546 2000 4 "01000" "10" 586 2000 1 "01000" "10" 868 2000 2 "01000" "10" 839 2000 3 "01000" "10" 952 2000 4 "01000" "10" 902 2000 1 "01000" "101" 713 2000 2 "01000" "101" 703 2000 3 "01000" "101" 914 2000 4 "01000" "101" 765 2000 1 "01000" "1013" 713 2000 2 "01000" "1013" 703 2000 3 "01000" "1013" 914 2000 4 "01000" "1013" 765 2000 1 "01000" "102" 877 2000 2 "01000" "102" 846 1990 1 "01000" "33299" 713 1990 2 "01000" "33299" 703 1990 3 "01000" "33299" 914 1990 4 "01000" "33299" 765 1990 1 "01000" "332993" 713 1990 2 "01000" "332993" 703 1990 3 "01000" "332993" 914 1990 4 "01000" "332993" 765 1990 1 "01000" "44-45" 317 1990 2 "01000" "44-45" 318 1990 3 "01000" "44-45" 334 1990 4 "01000" "44-45" 356 1990 1 "01001" "445" 525 1990 2 "01001" "445" 481 1990 3 "01001" "445" 611 1990 4 "01001" "445" 519 end
I figure that I need to create the number of population for each age group, race and gender in a wide format for each year and a county so that I can easily merge all the different age group , race , gender population with my master data merging on the variable of year and county.
Can anyone kindly tell me how I can create the wide format of my using data for variables age, race , gender , hispanic on the basis of pop value ( the number of population for those categories in those counties for that particular year).

Comment