Hello,
I am currently trying to reshape a dataset to the long format.
I have monthly return data over several years for 100 stocks. The months represented in the rows, the company id´s (e.g. US9129091081) in the columns (the returns are below the id´s therefore). Additionally I have monthly market returns as the last column, similar to the companies. I want to create a panel data set (long format), where every company is listed in the rows with the corresponding date and the market return on that month. Hence I want to assign the market returns of every month to every company as well.
I first created stub names for every single company. I just added a ret prefix to every id. Then I entered the following code:
Then I entered:
Could you please verify, if the code is indeed correct? I was not sure, because I completely excluded the market variable in the reshape command. I would appreciate a short feedback. Thank you in advance
I am currently trying to reshape a dataset to the long format.
I have monthly return data over several years for 100 stocks. The months represented in the rows, the company id´s (e.g. US9129091081) in the columns (the returns are below the id´s therefore). Additionally I have monthly market returns as the last column, similar to the companies. I want to create a panel data set (long format), where every company is listed in the rows with the corresponding date and the market return on that month. Hence I want to assign the market returns of every month to every company as well.
I first created stub names for every single company. I just added a ret prefix to every id. Then I entered the following code:
Code:
reshape long ret, i(date) j(id) string
Code:
sort id date

Comment