Hi,
I need to use the reshape command within a program, using newly generated variables month_1 month_2, etc.
I understand that, inside a program, newly generated variables must be first defined as tempvar, and then called as if they were local variables.
Therefore, I am asking this question in these terms:
How can I use the reshape command with local variables?
For example, this is working:
How can I make it work when month_1 and month_2 are local variables?
The try below obviously does not work, but I post it here to give the idea of what I am trying to do. Thanks
I need to use the reshape command within a program, using newly generated variables month_1 month_2, etc.
I understand that, inside a program, newly generated variables must be first defined as tempvar, and then called as if they were local variables.
Therefore, I am asking this question in these terms:
How can I use the reshape command with local variables?
For example, this is working:
Code:
sysuse auto, clear gen bene_id = _n gen month_1 = 0 gen month_2 = 0 reshape long month_, i(bene_id) j(month) reg price mpg weight length
The try below obviously does not work, but I post it here to give the idea of what I am trying to do. Thanks
Code:
sysuse auto, clear gen bene_id = _n local month_1 = 0 local month_2 = 0 reshape long month_, i(bene_id) j(month) reg price mpg weight length
Comment