Page 1 of 1

Importing time series from a table

Posted: Fri Nov 11, 2016 3:41 am
by zezza
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

Re: Importing time series from a table

Posted: Fri Nov 11, 2016 4:24 am
by EViews Gareth
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

Re: Importing time series from a table

Posted: Fri Nov 11, 2016 4:48 am
by zezza
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...

Re: Importing time series from a table

Posted: Fri Nov 11, 2016 7:30 am
by EViews Gareth
Yes, although if you name them differently you can do the page stack and restructure just once

Re: Importing time series from a table

Posted: Fri Nov 11, 2016 1:45 pm
by zezza
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?

Re: Importing time series from a table

Posted: Fri Nov 11, 2016 3:26 pm
by EViews Gareth
Import