Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: foreach program


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: Re: foreach program
Date   Fri, 08 Sep 2006 12:47:08 -0400

Yes -- that's right. Sorry for the typo.

I just ran the code on the Ohio 5% sample (which I happened to have on my computer and contains about 500k person records) and it created a dataset with the ir variable for 171 demographic cells in just under 4 seconds. I think you can do the whole country in a little less than "days" and probably more like a couple of minutes:) I noticed that about 50 cells had no one incarcerated, which led to missing values for the ir variable. Therefore, you should probably tack on an extra command at the end:

replace ir=0 if (perwt1==. | perwt1==0)

Michael Blasnik
[email protected]


----- Original Message ----- From: "Scott Cunningham" <[email protected]>
To: <[email protected]>
Sent: Friday, September 08, 2006 12:39 PM
Subject: Re: st: Re: foreach program



Michael,

gen byte groupqtrs=(gqtyped==200)
keep fip race sex agecat groupqtrs
collapse (sum) perwt, by(fip race sex agecat groupqtrs)
reshape wide perwt, i(fip race sex agecat) j(groupqtrs)
gen totpersons=perwt0+perwt1
gen ir=perwt1/totpersons
Just so I understand what you're doing, the second line should be:

. keep fip race sex agecat groupqtrs perwt

right? Because you use perwt in the third line, so I'm just wanting to make sure I understand.
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index