Hi,
I have a question regarding the loop!
I generated a variable and replaced it like this;
gen tele_among_full=.
replace tele_among_full=2 if full==1 & E6==6
replace tele_among_full=1 if full==1 & (E6==3|E6==4|E6==5)
replace tele_among_full=0 if full==1 & (E6==1 |E6==2)
but my supervisor said full==1 is repeated so there is an easier way to do and showed me this;
forvalues full==1{
replace tele_among_full=2 if E6==6
replace tele_among_full=1 if E6==3|E6==4|E6==5
replace tele_among_full=0 if E6==1 |E6==2
}
but it is not working. I don't see how full==1 can be fit in 'if'.
Is it a correct code?
Thank you!
Related Posts with Forvalues loop for the repeated variable
Help with calculating the SDs for between and within measurements (Precision test)Dear all in Statalist, In our studies, we perform Precision test (closeness between repeated measur…
Panel data with shockHi, I am using a panel data which consists of individual's employment data from 1998-2017. I am try…
Randomly assigning treatment at a proportion to a variableHello. I have a variable X with, say, 10000 observations. I want to randomly assign a treatment valu…
Interpreting HR and use of stcrreg command in stata 15.1Hi, I am trying to do a competing risk regression trying to analyse the competing risks between diff…
bys x : egen useHello, I am a novice user of stata.... I ask you for help solving my problem generating new var... …
Subscribe to:
Post Comments (Atom)
0 Response to Forvalues loop for the repeated variable
Post a Comment