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!