Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte ID int year str6 qdate int ID2 double COMPACT byte QCOMPACT 1 2001 "2001q1" 3 -.33564 1 1 2001 "2001q1" 15 -.304 1 1 2001 "2001q2" 78 -.42 2 1 2001 "2001q2" 51 -.4168 2 1 2001 "2001q2" 54 -.40089 2 1 2001 "2001q2" 987 -.4 2 1 2001 "2001q3" 94 -.33 3 1 2001 "2001q3" 73 -.301 3 1 2001 "2001q3" 82 -.253 3 1 2001 "2001q3" 81 -.207 3 1 2001 "2001q3" 5 -.18 3 1 2001 "2001q3" 9 -.139 3 1 2001 "2001q4" 936 -.59 4 1 2001 "2001q4" 6 -.5501 4 1 2001 "2001q4" 91 -.52 4 1 2002 "2002q1" 12 -.657 5 1 2002 "2002q1" 46 -.524 5 1 2002 "2002q2" 79 -.8412 6 1 2002 "2002q3" 3 -.982 7 1 2002 "2002q3" 68 -.922 7 1 2002 "2002q3" 93 -.8126 7 1 2002 "2002q3" 96 -.735 7 1 2002 "2002q3" 16 -.62456 7 1 2002 "2002q3" 88 -.5921 7 1 2002 "2002q4" 82 -.4156 8 1 2002 "2002q4" 80 -.4056 8 1 2002 "2002q4" 70 -.3995 8 1 2002 "2002q4" 35 -.3524 8 end
First of all I would like to thank to creators and users (especially to the ones that spend their time to help others) of this very helpful forum.
I am trying to obtain annual data via calculating means of quarterly data.
As you can see above I have different number of quarterly observations for each quarter. As first step, I need to calculate means of each quarterly observations. Let's say: for 2001q1, I have 2 observations but 2001q2 I have 4 observations. By using these observations I need to obtain mean of COMPACT for firm 1 2001q1, 2001q2, 2001q3 and so on... I also need to implement same method to firm 2, 3 and so on.
After I calculate means of each quarter, then I need to use means of 4 quarters to get value for each year to be used as a dependent variable in a regression.
Only suitable command I think I could use to do this was -collapse- however, once I execute the command I have only 1 observation for each ID and rest of the observations and variables (such as ID2) disappeared.
Do you think I should stick with -collapse- or is there any other command that I can try?
Kind Regards
Omer Faruk
Comment