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'
}
Related Posts with Replacing observations with conditions using loop
Define nested loops for dependent and independent variablesI have a panel data set from 1970 to 2014 on yields and prices for four different crops. I need to r…
Two Stage Least Squares with multiple Fixed Effects (using reghdfe)Dear Statalist, I am trying to estimate a two stage least squares where both stages contain multipl…
How to add a constraint when matching using teffects psmatch, cem or psmatch2?Hello dear statalists, I am trying to match the houses sold at year t with similar houses sold in ye…
Dropping repeated columns from a matrixDear statalist, I have a matrix in which two or more columns are exactly same. Is there some way of…
How to genearte the list of vars for nodes using nw2fromedge command when the number of nodes exceeds 1000Hello, could someone help me on this question. I am using the network analysis command "nw2fromedge"…
Subscribe to:
Post Comments (Atom)
0 Response to Replacing observations with conditions using loop
Post a Comment