03-21-2015 01:08 PM
I have a longitudinal dataset with many firms each month , 9 years so I have (12*9) months for each firm an example of my dataset is mentioned below.
|ID||Monthend(MM/YYYY)||Returns(%)||Level (Diff in Returns)|
I would like to compute the variable 'Level" which is the difference in returns from T+1 and T . For example the Level for the ID 1212 in 092003 = Returns in 092003 - 082003 (2.8% - 2.5%). This should be for each ID , that is when the ID changes the first observation in Level variable should be '0' and from 2nd observation the difference is computed.
I was wondering whether First.ID and Last.ID method works for this. Could someone send me a sample code.
Need further help from the community? Please ask a new question.