Importing time series from a table

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

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

zezza
Posts: 13
Joined: Fri May 28, 2010 5:27 am

Importing time series from a table

Postby zezza » Fri Nov 11, 2016 3:41 am

I sometime have the following problem: I have a quarterly time series published as a table, as in this Excel file, range O8::S26
http://www.turkstat.gov.tr/PreIstatisti ... ab_id=2272
namely
Q1 Q2 Q3 Q4
Year1 v v v v
Year2 v v v v
etc

where "v" stands for the numeric values of my quarterly time series X
I used to read these tables using the READ command in a loop, but I recently learned that the READ command is now deprecated.
I can read the table using a laborious loop, as in

Code: Select all

' Reads the four columns as annual series, named Series01 to Series04
copy(c=r) annual\series* quarterly\
pageselect quarterly
series gdp
for !year=1998 to 2016
   for !q = 1 to 4
      smpl {!year}Q{!q} {!year}Q{!q}
      gdp = series0{!q}
   next
next
smpl @all


But I am wondering if there is a simpler solution...
Thank you for your support

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

Re: Importing time series from a table

Postby EViews Gareth » Fri Nov 11, 2016 4:24 am

Here's one attempt

Code: Select all

wfopen(type=excel) http://www.turkstat.gov.tr/PreIstatistikTablo.do?istab_id=2272 range="o8" names="q1 q2 q3 q4 annual"
pagestruct(freq=a, start=1998)
delete annual
pagestack(page=np) q?   'stack data into new page - panel with years as the date id and quarters as the cross-section id
alpha mydate = @datestr(@date, "YYYY") + "Q" + @str(@crossid) 'make an alpha containing the actual date
pagestruct @date(mydate) 'convert structure
Follow us on Twitter @IHSEViews

zezza
Posts: 13
Joined: Fri May 28, 2010 5:27 am

Re: Importing time series from a table

Postby zezza » Fri Nov 11, 2016 4:48 am

Thank you Gareth, it works nicely. I guess that if I want to read multiple tables in the same excel file I need to run the code for each table to be read...

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

Re: Importing time series from a table

Postby EViews Gareth » Fri Nov 11, 2016 7:30 am

Yes, although if you name them differently you can do the page stack and restructure just once
Follow us on Twitter @IHSEViews

zezza
Posts: 13
Joined: Fri May 28, 2010 5:27 am

Re: Importing time series from a table

Postby zezza » Fri Nov 11, 2016 1:45 pm

Thank you. But I think you cannot use the same wfopen command to read different non-adjacent blocks of data from the same excel file, correct?

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

Re: Importing time series from a table

Postby EViews Gareth » Fri Nov 11, 2016 3:26 pm

Import
Follow us on Twitter @IHSEViews


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 14 guests