Statalist The Stata Listserver


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

st: -foreach-


From   "Ward Vanlaar" <wardv@trafficinjuryresearch.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: -foreach-
Date   Thu, 15 Feb 2007 15:37:33 -0500

Dear all,
 
I have a list of variables Q10A to Q10N and wrote the following piece of
code to run a set logistic regression analyses with each of those
variables as the dependent variable:
 
foreach var of varlist Q10A-Q10N ///
{
generate `var'rec=.
replace `var'rec=0 if `var'==2
replace `var'rec=1 if `var'==1
xi i.Q6 i.Q17 i.Q18
svy: logistic `var'rec _IQ6* Q7rec Q15 Q16 _IQ17* _IQ18* Q21
drop _I*
}
 
I also have a list of variables Q11A to Q11N and somehow I want to make
my code include Q11A in -xi- and -svy:logistic- as an independent
variable of the dependent variable Q10Arec; Q11B in -xi- and
-svy:logistic- as an independent variable of the dependent variable
Q10Brec; Q11C for Q10Crec and so on.
 
Any suggestions would be much appreciated!

Ward
 



*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index