Simple pageunstack gone wrong

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

paues
Posts: 218
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Simple pageunstack gone wrong

Postby paues » Fri May 29, 2026 9:46 pm

I want to import the attached (minimal) text files and unstack them into dated pages with two series: a and b. The text files differ with respect to the value column. The first file (test.txt) has variation in both the name and time dimension (i.e. all unique values), the second (test2.txt) has variation in the name dimension and the third (test3.txt) has variation in the time dimension.

test.txt

Code: Select all

name period value a 2000 1 a 2001 2 b 2000 3 b 2001 4
test2.txt

Code: Select all

name period value a 2000 1 a 2001 1 b 2000 2 b 2001 2
test3.txt

Code: Select all

name period value a 2000 1 a 2001 2 b 2000 1 b 2001 2

I thought that the following two steps would have worked for all the files.

First load the page and unstack it

Code: Select all

pageload .\test.txt pageunstack name dateid @ value
to get the series valuea and valueb (as well as a series dateid, a pool name and a group value) and then do some cleanup

Code: Select all

delete name value dateid rename value* *
And this does work for the first two files, test.txt and test2.txt. But for test3.txt the first step doesn't create the series valuea and valueb (nor the group value) but instead a single series value. And then the second step naturally results in an empty page (albeit correctly dated).

What to do?
Attachments
test3.txt
(57 Bytes) Downloaded 5 times
test2.txt
(57 Bytes) Downloaded 5 times
test.txt
(57 Bytes) Downloaded 4 times

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

Re: Simple pageunstack gone wrong

Postby EViews Gareth » Fri May 29, 2026 11:17 pm

The issue is that because there is no between cross-section variation (a and b are identical), when you stack, EViews does the "smart" thing in realising you don't need two different value series, so it condenses down to a single series, called value. Then when you do the tidyup step, you delete it.

Really the only way around this is to test whether there are any series called VALUE[X] before doing the tidyup.

paues
Posts: 218
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Re: Simple pageunstack gone wrong

Postby paues » Sat May 30, 2026 2:17 am

And then loop over the pool name and create the missing series? Something like this:

Code: Select all

pageload .\test.txt pageunstack name dateid @ value if @isempty(@wlookup("value", "group")) then %crossids = name.@crossids for %crossid {%crossids} copy value value{%crossid} next endif delete name value dateid rename value* *

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

Re: Simple pageunstack gone wrong

Postby EViews Gareth » Sat May 30, 2026 6:00 am

Yeah, that’s not a bad way to do it.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests