Pageload command does not structure workfile properly

For questions regarding programming in the EViews programming language.

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

chester
Posts: 44
Joined: Thu May 12, 2016 11:14 am

Pageload command does not structure workfile properly

Postby chester » Thu Nov 10, 2016 1:17 pm

I have data that is labelled by group. For groups with the word "Quarterly" in them, I'd like to import them into a workfile page that is structured in a Quarterly format. For some reason '@freq q' does not structure the workfile in a quarterly format but '@freq a' or '@freq m' structures the workfile properly. I attached a screenshot of the ID series and my code is below. Any help is appreciated! :D
eviewsstructure.PNG
eviewsstructure.PNG (7.15 KiB) Viewed 5694 times

Code: Select all

%frequency="" if @instr(uniquegroups(result+1),"Annual")>0 then %frequency = "a" endif if @instr(uniquegroups(result+1),"Quarterly")>0 then %frequency = "q" endif if @instr(uniquegroups(result+1),"Monthly")>0 then %frequency = "m" endif pageload "P:\Knowledge\Data Resources\Databases\Scraper\newdata.csv" ftype=ascii rectype=crlf skip=0 fieldtype=delimited delim=comma byrow colhead=2 namepos=first eoltype=pad badfield=NA @freq {%frequency} @smpl @all

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Pageload command does not structure workfile properly

Postby EViews Steve » Thu Nov 10, 2016 2:08 pm

Can you post (or just a portion of) your CSV file?

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

Re: Pageload command does not structure workfile properly

Postby EViews Gareth » Thu Nov 10, 2016 4:34 pm

@instr is case sensitive - I would guess you are never entering the if statement

chester
Posts: 44
Joined: Thu May 12, 2016 11:14 am

Re: Pageload command does not structure workfile properly

Postby chester » Mon Nov 14, 2016 9:53 am

Can you post (or just a portion of) your CSV file?
It appears EViews will not read quarterly time series data if it follows the format: "Q1 2012" - for example.
The workfile with imported data is unstructured.
However, if the data follows the format: "2012 Q1", the resulting workfile comes out structured as it should.

Is there any work-around here?

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Pageload command does not structure workfile properly

Postby EViews Steve » Mon Nov 14, 2016 11:18 am

Without changing the format of your date string, I can think of two options:

First, assuming your data is regular (meaning there are no gaps in the date column), you can simply import your data with a hard-coded frequency and start date - this will force the destination workfile to use your frequency and as long as the first data row matches the first hard-coded start date, the data should line up appropriately, like this:

Code: Select all

import c:\files\q_year.csv @freq Q 1948Q4
This is the simplest option.



If your date values are not regular or you'd rather not specify a hard-coded start date, you can do the following instead:

First, import everything into a new undated workfile first (and make sure to read in your date column as an alpha series):

Code: Select all

import c:\files\q_year.csv @freq U 1
Then create a new date series (i named mine DT2) that uses our @dateval function to convert your date column string (my date string column was named DT) into an actual date, like this (note the literal [Q] specified in the format string - this string is case sensitive so you must match it exactly to your date string):

Code: Select all

series dt2 = @dateval(dt, "[Q]Q YYYY")
Then finally use the pagestruct command to restructure your workfile to use the new date series as your frequency:

Code: Select all

pagestruct @date(dt2)
Once you have the workfile converted to the proper frequency, you can use the COPY command to put your new series objects into any pre-existing workfile that is already open.

Code: Select all

copy Q_YEAR::* PREEXISTINGWF::*
To cleanup, you can simply close the workfile that was created during the import:

Code: Select all

wfclose Q_YEAR
Steve

chester
Posts: 44
Joined: Thu May 12, 2016 11:14 am

Re: Pageload command does not structure workfile properly

Postby chester » Tue Nov 15, 2016 1:59 pm

Thanks for the suggestion. I managed to find a work-around that formats my CSV data directly so EViews can read it.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests