<>
What exactly are those "d31b_`i'"? If they are variables, then the -if-
qualifiers are evaluated for the first value only. This may be what you
want, but experience shows that users are unaware of this more often than
they actually want it. If you could give a description of your data and what
you want to achieve, I am quite sure that you will soon get a much easier
solution...
HTH
Martin
_______________________
----- Original Message -----
From: "Sabrina Carrossa" <[email protected]>
To: <[email protected]>
Sent: Monday, April 06, 2009 8:25 PM
Subject: st: local macro with if qualifier
Dear all,
how can i use a local macro with the if qualifier option?
Unfortunately, this code doesn't work:
local i=`i'+1 if d31b_`i'!=d31b_`y' & d31b_`i'==0 & `y'<3
Thank you in advance.
The full code is:
gen amico=0
local i=1
set trace on
forval y=2/3 {
replace amico=`i' if d31b_`i'!=d31b_`y' & d31b_`i'==1 & `y'==3
replace amico=`i' if d31b_`i'==d31b_`y' & d31b_`i'==1 &
d31c_`i'>d31c_`y' & `y'==3
replace amico=`i' if d31b_`i'==d31b_`y' & d31b_`i'==1 &
d31c_`i'==d31c_`y' & d31d_`i'>d31d_`y' & `y'==3
replace amico=`i' if d31b_`i'==d31b_`y' & d31b_`i'==1 &
d31c_`i'==d31c_`y' & d31d_`i'==d31d_`y' & `y'==3
replace debug=1 if d31b_`i'==d31b_`y' & d31b_`i'==1 &
d31c_`i'==d31c_`y' & d31d_`i'==d31d_`y' & `y'==3
replace amico=`y' if d31b_`i'!=d31b_`y' & d31b_`i'==0 & `y'==3
replace amico=`y' if d31b_`i'==d31b_`y' & d31b_`i'==1 &
d31c_`i'<d31c_`y' & `y'==3
replace amico=`y' if d31b_`i'==d31b_`y' & d31b_`i'==1 &
d31c_`i'==d31c_`y' & d31d_`i'<d31d_`y' & `y'==3
replace amico=`y' if d31b_`i'==d31b_`y' & d31b_`i'==1 &
d31c_`i'==d31c_`y' & d31d_`i'==d31d_`y' & `y'==3
local i=`i'+1 if d31b_`i'!=d31b_`y' & d31b_`i'==0 & `y'<3
local i=`i'+1 if d31b_`i'==d31b_`y' & d31b_`i'==1 &
d31c_`i'<d31c_`y' & `y'<3
local i=`i'+1 if d31b_`i'==d31b_`y' & d31b_`i'==1 &
d31c_`i'==d31c_`y' & d31d_`i'<d31d_`y' & `y'<3
}
set trace off
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/