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"
Identify observations in >1 variableHello, I wonder if anyone could help with the following: I have 2 variables with unique identifica…
country specific time trends, multicolinearity and degrees of freedomHello, I am running regressions on fertility rates on yearly data for T = 15 and 34 countries. Durin…
Dividing the dataset into tertilesDear Statalist members, My actual dataset is large so i am posting an example here. Code: * Exam…
Splitting commandHe Everyone, Hope the dataex command is used correctly here! I need to split the county name. I on…
Exploratory factor analysis for continous and dichotomous variablesplo …
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