Hi all,
I'm new on here. I know some bits and pieces about STATA so am not completely green. The issue I have at the moment is:
I have a dynamic dataset (with basically thousands of variables (which are simply the returns of some investment vehicles)). I need to generate 6 lagged variables from every variable which name begins with "lux" and ends with either 1,23...3000. So my dataset has over 3000 variables numbered as lux1, lux2, lux3...lux3000. At the moment I generate lags like this (by entering a line in the command window). Can someone please advise how to create a loop or a line of code that would repeat this process for every single "lux" variable?
gen lux1lag1= lux1[n-1], gen lux1lag2= lux1[n-2], gen lux1lag3= lux1[n-3], gen lux1lag4= lux1[n-4], gen lux1lag5= lux1[n-5], gen lux1lag6= lux1[n-6]
Thanks
West
I'm new on here. I know some bits and pieces about STATA so am not completely green. The issue I have at the moment is:
I have a dynamic dataset (with basically thousands of variables (which are simply the returns of some investment vehicles)). I need to generate 6 lagged variables from every variable which name begins with "lux" and ends with either 1,23...3000. So my dataset has over 3000 variables numbered as lux1, lux2, lux3...lux3000. At the moment I generate lags like this (by entering a line in the command window). Can someone please advise how to create a loop or a line of code that would repeat this process for every single "lux" variable?
gen lux1lag1= lux1[n-1], gen lux1lag2= lux1[n-2], gen lux1lag3= lux1[n-3], gen lux1lag4= lux1[n-4], gen lux1lag5= lux1[n-5], gen lux1lag6= lux1[n-6]
Thanks
West
Comment