Hello I have a varlist of variables (ex.10 variables) for 2017 and a varlist that contain same variables but for 2018 (10 variables). I would like to join them in 10 columns containing 2017 and then 2018 all together in the same column. But I would like to do it directly for all the variables without doing it one variable at the time. Is ther a way to do it?
Ex. of variables from first varlist 2017
T1_1_FirstClick T1_1_LastClick T1_1_PageSubmit T1_2_FirstClick T1_2_LastClick T1_2_PageSubmit --_> global time2017
the same variables for second varlist 2018
T1_1_First_Click T1_1_Last_Click T1_1_Page_Submit T1_2_First_Click T1_2_Last_Click T1_2_Page_Submit --> global time2018
each variable has a number of values and then empty cells where it corresponds to the values for 2018 and viceversa for 2018
T1_1_FirstClick
349
4859
5930
39595
.
.
.
.
while
T1_1_First_Click
.
.
.
.
5758
58483
48584
5858
I tried a global but cannot understand how to work together with two globals.
foreach w of global time2017 {
g `w'_new= `w'
foreach w of global time2018 {
replace XXXX `w' if XXX=.
here XXXX should be the corresponding variable of the newly created varibales T1*_new. But stata does not accept a varlist there
Ex. of variables from first varlist 2017
T1_1_FirstClick T1_1_LastClick T1_1_PageSubmit T1_2_FirstClick T1_2_LastClick T1_2_PageSubmit --_> global time2017
the same variables for second varlist 2018
T1_1_First_Click T1_1_Last_Click T1_1_Page_Submit T1_2_First_Click T1_2_Last_Click T1_2_Page_Submit --> global time2018
each variable has a number of values and then empty cells where it corresponds to the values for 2018 and viceversa for 2018
T1_1_FirstClick
349
4859
5930
39595
.
.
.
.
while
T1_1_First_Click
.
.
.
.
5758
58483
48584
5858
I tried a global but cannot understand how to work together with two globals.
foreach w of global time2017 {
g `w'_new= `w'
foreach w of global time2018 {
replace XXXX `w' if XXX=.
here XXXX should be the corresponding variable of the newly created varibales T1*_new. But stata does not accept a varlist there
Comment