Hi, I need some help
I'm working with migration data and I'd like to replace the values of the variable p10 by adding "01" to the observation by using a loop.
This is what I want to do:
replace p10 = 101 if p10==1
replace p10 = 201 if p10==2
replace p10 = 301 if p10==3
replace p10 = 401 if p10==4
replace p10 = 501 if p10==5
replace p10 = 601 if p10==6
replace p10 = 701 if p10==7
replace p10 = 801 if p10==8
replace p10 = 901 if p10==9
replace p10 = 1001 if p10==10
This is the loop that is not working
forvalues i = 1/10 {
replace p10 = `i'01 if p10 = `i'
}
0 Response to Replacing observations with conditions using loop
Post a Comment