panel data: calculate a cross-section as the sum of 2 others

For questions regarding programming in the EViews programming language.

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

lenka
Posts: 10
Joined: Wed Jun 05, 2013 8:29 am

panel data: calculate a cross-section as the sum of 2 others

Postby lenka » Wed Jun 05, 2013 8:35 am

Hi,
I have a panel, containing US50, USTER and USA cross-sections. I need to define USA as the sum of US50 and USTER for all variables. I am struggling with how to do this. Thank you
Lenka

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

Re: panel data: calculate a cross-section as the sum of 2 ot

Postby EViews Gareth » Wed Jun 05, 2013 8:57 am

Probably an easier way, but this will work:

Code: Select all

group all x y z sample s1 if cross="USTER" or cross="US50" for !i=1 to all.@count smpl @all %n = all.@seriesname(!i) series temp = @sumsby({%n}, @obsid, s1) smpl if cross="USA" {%n} = temp d temp next smpl @all
Where you replace "x y z" with the names of your variables, and "cross" with the name of your cross-section ID series.

lenka
Posts: 10
Joined: Wed Jun 05, 2013 8:29 am

Re: panel data: calculate a cross-section as the sum of 2 ot

Postby lenka » Fri Jun 07, 2013 3:09 am

Thanks,
works perfect.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest