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"
Problem with data managingHi, this is my first time posting here. My data has a problem. When importing my data, some lines ha…
select pairs of cases with a distance between them <18 monthsHi everyone. I need to select the MRIs that are less than 18 months apart. Thank you very much ---…
Create a new indicatorHello everyone, I have this 30 year panel data with he name and identifier of executives. I also ha…
how to make new variable based on existing variable?Hello! I have this categorical variable "education" No education 0 High School 1 Collage 2 PhD 3 …
Corresponding Dates with Business Calendar DatesHi I am working with the following data: Code: * Example generated by -dataex-. To install: ssc i…
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