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
Replacing Contents of All VariablesI have a data set in which I have students' grades for their 30 subjects aprox. These are letter gra…
Smoothing Kaplan Meier CurvesHello STATA Community, I am a new STATA user and I am trying to compute smooth Kaplan Meier curves.…
Syntax of cross-classified multilevel modelDear Statalist, I need to analyze data with complex structures. My data set consists of individuals…
Adding time variablesHi, I am currently working with time data. The following is the time each person spends alone on ea…
ppml: Number of regressors excludedHi, I am using the PPML estimator but I am not really sure what does it mean?: "Number of regresso…
Subscribe to:
Post Comments (Atom)
0 Response to Forvalues loop for the repeated variable
Post a Comment