Statalist The Stata Listserver


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

Re: st: assigning codes to variables in bulk


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: assigning codes to variables in bulk
Date   Thu, 23 Feb 2006 12:25:45 -0500

At 12:14 PM 2/23/2006, you wrote:
I am doing the following and fervently believe that there are more
elegant, faster ways to do this. (I am working in Stata 8.2 but will be
updating to 9 any day now.) Occupational history codes jobnum1-jobnum16
each take one of 500 values from 003 to 909, and I am assigning a
Nam-Powers status value (1 to 100) to each occupation held.

forvalues i=1 to 16{
gen jobstatus`i'=.
}
how about (not tested)

forvalues i = 1 to 16 {
recode jobnum`i' (003=86)(004=77)..., gen(jobstatus`'i')
}

or else something like

recode jobnum1 jobnum2...jobnum16 (003=86)..., gen(jobstatus1 jobstatus2...)

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc
*
* 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