It works fine...much appreciated!
Ward
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Sergio
Correia
Sent: Thursday, February 15, 2007 4:03 PM
To: [email protected]
Subject: Re: st: -foreach-
Maybe this helps:
Before the -svy- command, write
local indepvar = "Q11" + substr("`var'",-1,1)
and now you can use `indepvar'
Sergio
On 2/15/07, Ward Vanlaar <[email protected]> wrote:
> 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/
>
*
* 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/
*
* 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/