Page 1 of 1

Import mixed data

Posted: Mon Mar 12, 2012 2:42 pm
by PMaier
Hi,

I could use some help on importing a somewhat complex CSV file. The file is structured as follows:
INDX_NM INDX_DESC SCE_NM PERIOD VALUE
UST 3M US Treasury Bill (3M) TDA_U1 6/1/2004 1.088
UST 3M US Treasury Bill (3M) TDA_U1 9/1/2004 1.5037
UST 3M US Treasury Bill (3M) TDA_U1 12/1/2004 2.0338
UST 3M US Treasury Bill (3M) TDA_U1 3/1/2005 2.5748
UST 10Y US Treasury Note (10Y) TDA_U1 6/1/2004 4.5864
UST 10Y US Treasury Note (10Y) TDA_U1 9/1/2004 4.3082
UST 10Y US Treasury Note (10Y) TDA_U1 12/1/2004 4.1742
UST 10Y US Treasury Note (10Y) TDA_U1 3/1/2005 4.2996
FFTGTAVG Average Target Federal TDA_U1 6/1/2004 1
FFTGTAVG Average Target Federal TDA_U1 9/1/2004 1.413
FFTGTAVG Average Target Federal TDA_U1 12/1/2004 1.9348
FFTGTAVG Average Target Federal TDA_U1 3/1/2005 2.4333
UST 3M US Treasury Bill (3M) TDA_U2 6/1/2004 1.088
UST 3M US Treasury Bill (3M) TDA_U2 9/1/2004 1.5037
UST 3M US Treasury Bill (3M) TDA_U2 12/1/2004 2.0338
UST 3M US Treasury Bill (3M) TDA_U2 3/1/2005 2.5748
UST 10Y US Treasury Note (10Y) TDA_U2 6/1/2004 4.5864
UST 10Y US Treasury Note (10Y) TDA_U2 9/1/2004 4.3082
UST 10Y US Treasury Note (10Y) TDA_U2 12/1/2004 4.1742
UST 10Y US Treasury Note (10Y) TDA_U2 3/1/2005 4.2996
FFTGTAVG Average Target Federal TDA_U2 6/1/2004 1
FFTGTAVG Average Target Federal TDA_U2 9/1/2004 1.413
FFTGTAVG Average Target Federal TDA_U2 12/1/2004 1.9348
FFTGTAVG Average Target Federal TDA_U2 3/1/2005 2.4333
The complication is that the entire file is pretty big, but I only need parts of it. For instance, I'm only interested in the first two observations (2004Q2+Q3), and I would like to filter such that I only get FFTGTAVG and discard, say, UST 10Y.

I've been experimenting with the import file, but I have to say that I haven't been terribly successful. For instance, if my file has a date range of, say, 2004Q2-2004Q3, then the command

import %file @freq q 2004q2

reads in data for the first variable (UST 3M), not for all of them. Also, in an ideal world, I could directly use some of the information in the table to name the variables, such as use sce_nm as part of the variable name ("var_{%sce_nm}").

Any help would be appreciated,

Philipp

Re: Import mixed data

Posted: Mon Mar 12, 2012 2:55 pm
by EViews Gareth
You could use the @smpl argument to filter which observations to import. Something like:

Code: Select all

@smpl 2004q2 2004q3 if indx_nm = "FFTGTAVG"

Re: Import mixed data

Posted: Tue Mar 13, 2012 4:47 am
by PMaier
Unfortunately - it doesn't seem to work.

I uploaded a sample file. When I run the following code:

Code: Select all

wfcreate(wf=Test) q 2004 2012 import(resize) "Test.csv" @drop modeler fcst_month @freq q 2004q2 @smpl 2010q1 2012q4 if INDX_NM="FFTGTAVG"
I get the following error:

Error in Sample: INDX_NM is not defined in "IMPORT(TYPE="TEXT")....

Any idea why? If I don't use the smpl if-command, the variable INDX_NM is imported correctly, so it doesn't seem to be the case that Eviews doesn't properly recognize the variable.

Many thanks, Philipp

Re: Import mixed data

Posted: Tue Mar 13, 2012 8:16 am
by EViews Gareth
Sorry, my bad. Try this:

Code: Select all

import(resize) "Test.csv" @drop modeler fcst_month @freq q 2004q2 @smpl 2010q1 2012q4 @selectif INDX_NM="FFTGTAVG"

Re: Import mixed data

Posted: Tue Mar 13, 2012 9:08 am
by PMaier
Thanks, Gareth. This works.

One more question:

I will need different parts of the file (different values for "indx_nm", so to speak), and I can loop through them. However, given how large the original file is, it take a really long time to load it every time the loop is executed.

Is there a way I can import the whole file into a matrix or table? I tried matrix.read, but all the string values stay empty. A table would work, I guess, but there doesn't seem to be an import functionality for tables?

Any other thoughts would be appreciated,

Philipp

Re: Import mixed data

Posted: Tue Mar 13, 2012 9:11 am
by EViews Gareth
No. The only way to bring it all in would be to bring it in as a separate page (using pageload), and then copy from the big page to the smaller page.