Page 1 of 1

Structuring panel data

Posted: Wed Jan 21, 2015 11:17 am
by tvonbrasch
Hi

I have created an example similar to the "Kansas" example in the help menu for structuring panel data (see the first table below and the attached excel file). There are two different observations for fnr=5. But for each dublicate of fnr, i want the fnr = 5 to be the sum of x for the duplicate year and registered to the industry where x is largest. In that case the data would be structured according to the second table below. (fnr=5 2004 192=164+28 1)

Can you please show me the code for creating a dated panel from this data?

In other words, i want the fnr to be the unique identifiers and i want lag operators to refer to the same fnr in the preceeding year (which is not the way it is done in the kansas example).

Thomas

fnr year x industry
1 2001 100 1
1 2002 150 1
1 2004 130 1
2 2002 120 1
2 2003 120 1
2 2004 156 1
3 2004 151 1
3 2005 164 1
3 2006 154 1
4 2002 135 1
4 2004 125 1
5 2001 176 1
5 2002 195 1
5 2003 154 1
5 2004 168 1
5 2004 24 2
5 2006 165 1



fnr year x industry
1 2001 100 1
1 2002 150 1
1 2004 130 1
2 2002 120 1
2 2003 120 1
2 2004 156 1
3 2004 151 1
3 2005 164 1
3 2006 154 1
4 2002 135 1
4 2004 125 1
5 2001 176 1
5 2002 195 1
5 2003 154 1
5 2004 192 1
5 2006 165 1

Re: Structuring panel data

Posted: Wed Jan 21, 2015 11:55 am
by EViews Gareth
Tricky, but fun, one.

Code: Select all

wfopen panel_data_structure.xlsx pagecreate(page=mypg, id) @date(year) fnr series year = @year copy(c=s) panel_data_structure\x mypg\x @src year fnr @dest year fnr copy(c=x) panel_data_structure\x mypg\xid @src year fnr @dest year fnr copy panel_data_structure\industry mypg\industry @src year fnr x @dest year fnr xid
The idea is to create a new page containing unique values of year and fnr. Then copy over X using the sum contraction method, so duplicate values of fnr will be summed.
Then the tricky bit is to match industry to the maximum value of X, so I copy X over again, this time using maximum as the contraction method, then I copy industry over, but this time using X and the maximum value of X as a matching series.

Re: Structuring panel data

Posted: Wed Jan 21, 2015 12:50 pm
by tvonbrasch
nice! thank you
thomas

Re: Structuring panel data

Posted: Thu Jan 22, 2015 4:52 am
by tvonbrasch
A quick follow up question.

I have a panel dataset similar to the one you helped me with, but where the number of observations are 20 million. It therefore takes some time to do operations on this workfile. It would be much easier to work with a smaller workfile.

From a balanced panel, as the one you generated above, how can I take out say XX per cent of the observations randomly and place them in a new workpage? (i.e., I want to take out XX per cent of the fnr variable and copy all information from other variables belonging to those fnr codes and for all years to another workfile)

Thomas

Re: Structuring panel data

Posted: Thu Jan 22, 2015 8:56 am
by EViews Gareth

Code: Select all

pagecopy(rndpct=!xx)

Re: Structuring panel data

Posted: Thu Jan 22, 2015 11:25 pm
by tvonbrasch
thanks, excellent function.
Thomas