Good day all,
I have 8 existing variables A, B, C, D, E, F, G, H.
For each variable I want to create a new variable for each year between 2000 and 2010, and name it as a combination of the variable name and year. For example A2000 A2001 A2002 etc.
The below code seems to fail.
Does anyone know what I'm doing wrong?
I have 8 existing variables A, B, C, D, E, F, G, H.
For each variable I want to create a new variable for each year between 2000 and 2010, and name it as a combination of the variable name and year. For example A2000 A2001 A2002 etc.
The below code seems to fail.
Does anyone know what I'm doing wrong?
Code:
foreach varname in A B C D E F G H{ foreach num of numlist 2000(1)2010{ gen `varname'+`num'=`varname' if year=`num' } }
Comment