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"
Calculating sample size with more parametersHello, I am trying to calculate sample size with the parameters below. I used the code below to cal…
Forest plots - how do I move the null reference line in meta forest?Hi, I am trying to make a Forest plot of odds ratios. The studies cannot be combined, I'm only tryi…
2SLS on Panel DataHi guys! I'm using 2SLS on Panel Data, however when I calculate 2SLS manually, I mean, by doing: F…
Resetting IndexHello, I have a panel dataset containing three vars: nation, year, and a variable called 'event' wh…
multiple criteria across several variablesHi there Sorry if this is really basic, but I want to flag every observation where both values 3 an…
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