Structuring panel data

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

tvonbrasch
Posts: 569
Joined: Fri Apr 15, 2011 5:35 am

Structuring panel data

Postby tvonbrasch » Wed Jan 21, 2015 11:17 am

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
Attachments
panel_data_structure.xlsx
(9.11 KiB) Downloaded 283 times

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Structuring panel data

Postby EViews Gareth » Wed Jan 21, 2015 11:55 am

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.

tvonbrasch
Posts: 569
Joined: Fri Apr 15, 2011 5:35 am

Re: Structuring panel data

Postby tvonbrasch » Wed Jan 21, 2015 12:50 pm

nice! thank you
thomas

tvonbrasch
Posts: 569
Joined: Fri Apr 15, 2011 5:35 am

Re: Structuring panel data

Postby tvonbrasch » Thu Jan 22, 2015 4:52 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Structuring panel data

Postby EViews Gareth » Thu Jan 22, 2015 8:56 am

Code: Select all

pagecopy(rndpct=!xx)

tvonbrasch
Posts: 569
Joined: Fri Apr 15, 2011 5:35 am

Re: Structuring panel data

Postby tvonbrasch » Thu Jan 22, 2015 11:25 pm

thanks, excellent function.
Thomas


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests