Suppose I have a dataset like this:
but with many more time periods.
And I would like a dataset with one firm-time period per observation like this.
This is sort of like transpose, but I need to retain the time period (which is the variable label in the first dataset). If it was only 3 time periods, it would be easy to do the long way (open the dataset 3 times, save the relevant time period, add the time value, then append the 3 files). But if there are 100 time periods, that way is not efficient (not that its efficient if there are only 3 time periods). What is an efficient way to convert the data into the second format?
Thanks in advance.
Code:
clear input firm_id value_time1 value_time2 value_time3 1 3 -5 3 2 2 6 9 3 5 3 1 4 5 8 0 5 3 -4 6 end save temp1, replace
And I would like a dataset with one firm-time period per observation like this.
Code:
clear input firm_id time value 1 1 3 2 1 2 3 1 5 4 1 5 5 1 3 1 2 -5 2 2 6 3 2 3 4 2 8 5 2 -4 1 3 3 2 3 9 3 3 1 4 3 0 5 3 6 end save temp2, replace
Thanks in advance.

Comment