Export group to Excel

For questions regarding programming in the EViews programming language.

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

Phil09
Posts: 12
Joined: Fri Mar 17, 2017 11:10 am

Export group to Excel

Postby Phil09 » Fri Mar 17, 2017 11:17 am

I constructed a group object from panel data objects. When I export the group to Excel with the following statement, the observation ID (date+cross section) is missing. How do I change that?

wfsave(type=excelxml) {%tableloc}state_backtest.xlsx range="forecast!b1" @smpl {%graph_sample} @keep __g_backtest

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

Re: Export group to Excel

Postby EViews Gareth » Fri Mar 17, 2017 11:31 am

Put the id series into the group.

When you tell EViews to just keep a group it literally only keeps the series in that group.
Follow us on Twitter @IHSEViews

Phil09
Posts: 12
Joined: Fri Mar 17, 2017 11:10 am

Re: Export group to Excel

Postby Phil09 » Fri Mar 17, 2017 12:13 pm

If the reason behind export failing to include observation ID is because the group does not retain it, then the following statement should do it:

wfsave(type=excelxml) {%tableloc}state_backtest.xlsx range="actual!a1" @keep {%varlist} @smpl {%graph_sample}

where %varlist is a list of panel data series. But this statement did not produce observation ID either in the Excel table either. The problem seems to lie with exporting panel data to Excel.

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

Re: Export group to Excel

Postby EViews Gareth » Fri Mar 17, 2017 2:13 pm

Code: Select all

wfcreate a 1990 2000 10
alpha mycrosssections = "myid" + @str(@crossid)
alpha mydates = @datestr(@date, "YYYY")
series y=@nrnd
group g mydates mycrosssections y

wfsave(type=excelxml) myfile.xlsx @keep g


Works just fine.
Follow us on Twitter @IHSEViews

Phil09
Posts: 12
Joined: Fri Mar 17, 2017 11:10 am

Re: Export group to Excel

Postby Phil09 » Fri Mar 17, 2017 4:40 pm

Great. It seems to me that I need to add the date and the cross section explicitly to the group.

Given a panel data series, how do I extract its date and cross section?

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

Re: Export group to Excel

Postby EViews Gareth » Fri Mar 17, 2017 5:18 pm

Code: Select all

alpha mycrosssections = "myid" + @str(@crossid)
alpha mydates = @datestr(@date, "YYYY")


or @pageids
Follow us on Twitter @IHSEViews

Phil09
Posts: 12
Joined: Fri Mar 17, 2017 11:10 am

Re: Export group to Excel

Postby Phil09 » Mon Mar 20, 2017 10:05 am

My panel data series is indexed by state abbreviation and date such as "AK - 50Q1". @crossid gives me index 1, ..., 50, rather than state abbreviation. How do I obtain the latter?

@PAGEIDS gives an error message: @PAGEIDS is not a Genr or series expression function.

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

Re: Export group to Excel

Postby EViews Gareth » Mon Mar 20, 2017 10:24 am

I'm a bit confused - do you know the name the of your cross-section identifier?
Follow us on Twitter @IHSEViews

Phil09
Posts: 12
Joined: Fri Mar 17, 2017 11:10 am

Re: Export group to Excel

Postby Phil09 » Mon Mar 20, 2017 10:32 am

The name of my cross section id is _P. For instance if I want to select a sample from the state of Alaska, I issue the following statement:
smpl 2008 2010 if _P="AK"

Eviews documentation on series object does not contain a lot of information on panel data series. Can you point me to some good reference?

Phil09
Posts: 12
Joined: Fri Mar 17, 2017 11:10 am

Re: Export group to Excel

Postby Phil09 » Mon Mar 20, 2017 10:35 am

I also wish to know how to extract a particular data point from my panel data series X. For instance, I wish to assign the value of the series value at 2010Q2 for the cross section of "AK" to a scalar. How do I reference that data point?

Phil09
Posts: 12
Joined: Fri Mar 17, 2017 11:10 am

Re: Export group to Excel

Postby Phil09 » Mon Mar 20, 2017 11:03 am

For a series without cross section, I can obtain the value at any date with @elem(X, "2010Q2"). When the series is a panel, I get the error message: "Date does not uniquely define observation in panels".

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

Re: Export group to Excel

Postby EViews Gareth » Mon Mar 20, 2017 11:23 am

Phil09 wrote:The name of my cross section id is _P. For instance if I want to select a sample from the state of Alaska, I issue the following statement:
smpl 2008 2010 if _P="AK"



So just include _p in the group?
Follow us on Twitter @IHSEViews

Phil09
Posts: 12
Joined: Fri Mar 17, 2017 11:10 am

Re: Export group to Excel

Postby Phil09 » Mon Mar 20, 2017 11:28 am

Gareth, thank you. That worked!

My mistake is that I kept on thinking that cross section ID is attribute of a panel data series. It is actually an object of the panel data workfile, in which all series have the same cross section ID.

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

Re: Export group to Excel

Postby EViews Gareth » Mon Mar 20, 2017 11:29 am

Phil09 wrote:I also wish to know how to extract a particular data point from my panel data series X. For instance, I wish to assign the value of the series value at 2010Q2 for the cross section of "AK" to a scalar. How do I reference that data point?


There is no @elem for panels, unfortunately. You'll have to set the sample to the observation you want, then use @max or something to extract the value.
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 6 guests