Easily add a cross section

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

mcabello
Posts: 7
Joined: Tue May 10, 2011 2:51 pm

Easily add a cross section

Postby mcabello » Tue May 10, 2011 3:23 pm

Hi!

A little question: how do I easily add a cross section to a panel? Suppose you have a panel structured as pagestruct @date(date) isocode, and that you want to extend the workfile in order to add a new isocode identifier, say "EGY", for Egypt. Is there a quick command to do this?

Thank you very much in advance.

Regards,
Matías Cabello

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

Re: Easily add a cross section

Postby EViews Gareth » Tue May 10, 2011 3:52 pm

It is actually really quite difficult, if you're not bringing data in from a foreign source, rather you're just adding a new empty cross-section. The following code will do it, assuming your panel is balanced:

Code: Select all

!obs = @obsrange 'total number of observations series t = @trend !timepers = @max(t) 'number of time periods !newobs = !obs + !timepers 'new total number of observations pagestruct(freq=u, start=1, end=!newobs) 'remove the panel structure, and add new observations to the workfile page smpl if @trend >= !obs 'set the sample to be just the newly added observations isocode = "EGY" 'set crossid date = date(-!timepers) 'set dateid smpl @all pagestruct @date(dateid) isocode

mcabello
Posts: 7
Joined: Tue May 10, 2011 2:51 pm

Re: Easily add a cross section

Postby mcabello » Tue May 10, 2011 5:40 pm

Gareth, thank you for the quick reply! Sad that there is no easy command as it is the case with adding more observations.
Regards,
Matías Cabello

niluki
Posts: 11
Joined: Wed Mar 30, 2011 3:24 am

Re: Easily add a cross section

Postby niluki » Mon Jul 02, 2012 8:51 am

Is there anyway that this could be adapted to an Unbalanced Structure?

Thanks,

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

Re: Easily add a cross section

Postby EViews Gareth » Mon Jul 02, 2012 8:52 am

Not really. Adding an arbitrary unbalanced cross-section is very difficult.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests