Dear stata-users,
I am writing you, because I hope that anyone here could help me out with your knowledge. Until now, I am not be able to solve it on my own by investigating the help from the Stata manual and forums. It would be wonderful if anyone have good advice!
I want to transpose my panel data, to make my situation more clear, I will illustrate my problem with an example of my panel data.
My own data consists of more than 600 banks over almost 10 years, but to make it easy I will illustrate my date with 3 banks for three days. This is the example of the current dataset:
permno date ticker Company name Cusip Ret
1. 10002 02/07/2007 BTFG Banctrust 05978R19 -2.892
2. 10002 03/07/2007 BTFG Banctrust 05978R19 1.434
3. 10002 04/07/2007 BTFG Banctrust 05978R19 2.324
4. 20395 02/07/2007 WJMK Warrior 61778Q19 1.343
5. 20395 03/07/2007 WJMK Warrior 61778Q19 3.233
6. 20395 04/07/2007 WJMK Warrior 61778Q19 2.233
7. 40234 02/07/2007 BJBP Banc Jones 20124B41 3.233
8. 40234 03/07/2007 BJBP Banc Jones 20124B41 -1.343
9.40234 04/07/2007 BJPP Banc Jones 20124B41 1.234
- Permno is an identifier of the company
- Date = Date
- Ret = Return of the shareprice
Now I want to transpose (like a pivot table in excel) the data to the following new data set:
date permno permno permno
10002 20395 40234
1. 02/07/2007 -2.892 1.343 3.233
2. 03/07/2007 1.434 3.233 -1.343
3. 04/07/2007 2.324 2.233 1.234
So in the new situation I want to have the permno (id) in the column. I want the date in the row. And as values, I want ret (the returns of the share prices of the company).
The problem now is when I use the following command: reshape wide ret, i(permno) j(date) , the problem with this command is that id (permno) stays in the row and you can not choose you what you want in the column, row or as values. I have dropped the other variables that I don't need, otherwise the above command won't work.
I hope that someone could help me out with this command to reach my goal. I am looking forward to hearing of someone, that would be awesome.
I am writing you, because I hope that anyone here could help me out with your knowledge. Until now, I am not be able to solve it on my own by investigating the help from the Stata manual and forums. It would be wonderful if anyone have good advice!
I want to transpose my panel data, to make my situation more clear, I will illustrate my problem with an example of my panel data.
My own data consists of more than 600 banks over almost 10 years, but to make it easy I will illustrate my date with 3 banks for three days. This is the example of the current dataset:
permno date ticker Company name Cusip Ret
1. 10002 02/07/2007 BTFG Banctrust 05978R19 -2.892
2. 10002 03/07/2007 BTFG Banctrust 05978R19 1.434
3. 10002 04/07/2007 BTFG Banctrust 05978R19 2.324
4. 20395 02/07/2007 WJMK Warrior 61778Q19 1.343
5. 20395 03/07/2007 WJMK Warrior 61778Q19 3.233
6. 20395 04/07/2007 WJMK Warrior 61778Q19 2.233
7. 40234 02/07/2007 BJBP Banc Jones 20124B41 3.233
8. 40234 03/07/2007 BJBP Banc Jones 20124B41 -1.343
9.40234 04/07/2007 BJPP Banc Jones 20124B41 1.234
- Permno is an identifier of the company
- Date = Date
- Ret = Return of the shareprice
Now I want to transpose (like a pivot table in excel) the data to the following new data set:
date permno permno permno
10002 20395 40234
1. 02/07/2007 -2.892 1.343 3.233
2. 03/07/2007 1.434 3.233 -1.343
3. 04/07/2007 2.324 2.233 1.234
So in the new situation I want to have the permno (id) in the column. I want the date in the row. And as values, I want ret (the returns of the share prices of the company).
The problem now is when I use the following command: reshape wide ret, i(permno) j(date) , the problem with this command is that id (permno) stays in the row and you can not choose you what you want in the column, row or as values. I have dropped the other variables that I don't need, otherwise the above command won't work.
I hope that someone could help me out with this command to reach my goal. I am looking forward to hearing of someone, that would be awesome.
Comment