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
Running stata commands within python: end blocks in Stata 16Dear Statalist users, I have to create a user-defined weighting function that weighs the independen…
Graph line to show the mean of two variables over a periodHello everyone. I need to know how to display a graph line that shows the mean of my Y variables by…
Reference Category for PPML hdfeHi All, I am making use of the wonderful command Code: ppmlhdfe which is used to estimate models w…
Eprobit, entreat: missing information in model output for error correlationsHello, I am missing running a series of models using eprobit, entreat in Stata 16.1. My model is: …
Error "not stata format", but no change in software or dataset, which previously worked fineDear Statalists, I am currently working with a dataset from the European Values Survey. The past we…
Subscribe to:
Post Comments (Atom)
0 Response to Forvalues loop for the repeated variable
Post a Comment