Hi everyone,
Using the below codes, I am trying to generate a new variable (long_X6 to long_X13) and replace its values by the values of the preceding variable or X5 to X12 (coded as `var'-1==2). I do not get any errors when run this code but nothing happens in the data.
Thanks,
Nader
foreach var of varlist X6-X13 {
replace long_`var'=2 if `var'-1==2
}
Related Posts with replacing values of a newly generated variable by the values of previous variables using "foreach var of varlist"
Dropping observations based on multiple conditionsHi. I am pasting a sample of the date of I am working with: Code: * Example generated by -dataex-.…
generating household size variableI'm using Household Income Expenditure Survey data for a research. But there is no variable called H…
Multiple Imputation on Panel Data - Error regarding variance-covariance matrix (EM did not converge)Dear All, I am tackling my thesis and i have panel data on around 150 companies between the years 2…
Computing predictive margins (mimrgns) for gsem with random effectsDear Statalisters, I would much appreciate your help with the following problem: I am not able to …
code for testing of multiple unknown structural breaksI´m using stata 16 with windows 10 OS. I want to identify multiple structural break of unknown date…
Subscribe to:
Post Comments (Atom)
0 Response to replacing values of a newly generated variable by the values of previous variables using "foreach var of varlist"
Post a Comment