Monday, March 20, 2006
I have the following dataset:
perwt year state msa county males females age race
My goal is to create sex ratios (ie ratios of males to females) for each county. I have not attempted this before because the way that I calculated sex ratios for states and cities (ie, msa) was to write a .do file that summed up the person weights (ie, perwt) for each state/msa. This was not so bad for states, but moreso for cities, since there are 350 cities. The number of counties are in the thousands, and since I have to create sex ratios that differ by race, age and year, it would require writing out a very long .do file. So my question is: is there a looping procedure I could use, which would use the county-level variable as the variable that does the operation? For instance, if there were two counties (1 and 2), then the loop would sum all males of the given age-race criteria, all females of the same age-race criteria, take the ratio and record that for county 1, then repeat for county 2, etc.
* * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/
Links to this post: