Page 1 of 1

Panel data form

Posted: Tue Mar 06, 2007 8:39 pm
by Gibbson
Dear All,


I have a data set is panel data form, but the order of year is from big to small.
For example;

Comapny Year EPS
A 2005 2
A 2004 1
A 2003 1.5
B 2005 3
B 2004 2
B 2003 4.1

Is there any Rats Code to transform the panel data form into new that the order of year is from small to big.
Like the following form:

Comapny Year EPS
A 2003 1.5
A 2004 1
A 2005 2
B 2003 4.1
B 2004 2
B 2005 3

Thank you very much for your help in advance!

C. M. Wang

Posted: Wed Mar 21, 2007 10:23 am
by TomM
Sorry, didn't see this post earlier.

The PFORM instruction can do this easily. The easiest approach would be to change your company codes from letters to series, so RATS can process them as series. Then, just do a single PFORM command per series to reorder the data. For example:

allocate 6
data(unit=input,org=cols) / Company Year EPS
1 2005 2
1 2004 1
1 2003 1.5
2 2005 3
2 2004 2
2 2003 4.1

pform(indiv=company,time=year) companypan
# company
pform(indiv=company,time=year) yearpan
# year
pform(indiv=company,time=year) epspan
# eps

calendar(panelobs=3)
print / companypan yearpan epspan


ENTRY COMPANYPAN YEARPAN EPSPAN
1//1 1 2003 1.5
1//2 1 2004 1.0
1//3 1 2005 2.0
2//1 2 2003 4.1
2//2 2 2004 2.0
2//3 2 2005 3.0