Page 1 of 1

Several observations per line

Posted: Fri Aug 31, 2012 12:51 am
by paues
I have a tab-separated text file containing a heap of quarterly series which are stored as a matrix. The columns contain the following information:

1. YEAR (contains value for all lines)
2. Part one of series name (contains value for all lines)
3. Part two of series name (contains value for some lines)
4. Value for first quarter (contains value for all lines)
5. Value for second quarter (contains value for all lines)
6. Value for third quarter (contains value for all lines) and
7. Value for fourth quarter (contains value for all lines)

I would like to (A) import the text file; (B) concatenate the series-name parts to one column, replacing all NA from column three with the string ""; and (C) unstack the matrix to get the quarterly series.

What I have so far is:

Code: Select all

wfopen(type=text,wf=tmp,page=matrix) C:\...\exampledata.txt names=(year, name01, name02, q1, q2, q3, q4) delim=tab pagestruct(none) alpha name=name01 + @str(name02) delete name01 name02 pagestruct name @date(year)

Re: Several observations per line

Posted: Fri Aug 31, 2012 7:58 am
by EViews Gareth
Tricky.

Code: Select all

wfopen(type=text) exampledata.txt names=(year, name01, name02, q1, q2, q3, q4) delim=tab alpha name = name01+@str(name02) pagestruct name @date(year) delete name01 name02 pagestack q? alpha date = @str(year) + "q" + @str(var01) pagestruct @date(date) name d dateid var01 rename q data pageunstack name date pagestruct @date(date) d data date dateid01 name year rename data* *

Re: Several observations per line

Posted: Mon Sep 03, 2012 1:20 am
by paues
Brilliant! That was much more straightforward than the approach I was trying. With this fixed there is the issue of giving the series more sensible names. I have another file (attached) which contains three columns:

1. part one of series name (same as column 2 in exampledata.txt),
2. part two of series name (same as column 3 in exampledata.txt), and
3. final series name.

How would one go about to map these to the matrix found in exampledata.txt and give the alpha series "name" the values specified in column 3 of examplemap.txt instead?

Re: Several observations per line

Posted: Tue Sep 04, 2012 9:48 am
by EViews Gareth

Code: Select all

wfopen(type=text) exampledata.txt names=(year, name01, name02, q1, q2, q3, q4) delim=tab alpha name = name01+@str(name02) pagestruct name @date(year) delete name01 name02 pagestack q? alpha date = @str(year) + "q" + @str(var01) pagestruct @date(date) name d dateid var01 rename q data pageunstack(page=mypage) name date pagestruct @date(date) d data date dateid01 name year rename data* * pageload examplemap.txt !length = @obsrange alpha name = series01 + @str(series02) table names for !i=1 to !length names(!i,1) = name(!i) names(!i,2) = series03(!i) next copy names mypage\names pagedelete examplemap pageselect mypage for !i=1 to !length %name1 = names(!i,1) %name2 = names(!i,2) rename {%name1} {%name2} next

Re: Several observations per line

Posted: Fri Dec 21, 2012 7:01 am
by paues
I have discovered another problem with this issue. In the attached workfile I have two pages (named one and two). Each page holds a 6-dimensional panel that in the end should be transformed to quarterly series (as per my initial post here above).

1. NAME (what the final quarterly series should be called)
2. YEAR
3. Q1 (series NAME's value for the first quarter in each YEAR)
4. Q2 (series NAME's value for the second quarter in each YEAR)
5. Q3 (series NAME's value for the third quarter in each YEAR)
6. Q4 (series NAME's value for the fourth quarter in each YEAR)

In line with suggestions from Gareth (in the second post in this topic) I have written the following code.

Code: Select all

for %pg one two pageselect exampledata\{%pg} pagestruct name @date(year) pagestack q? alpha date=@str(year)+"Q"+@str(var01) pagestruct @date(date) name delete dateid var01 pageunstack name date pagestruct @date(date) delete q date dateid01 name year next
However, page two returns an error ('Illegal panel structure DATEID is nested within NAME in "PAGESTRUCT NAME @DATE(YEAR)".') - from what I can tell relating to the fact that all the values in page two are for the year 2012. This however should not be a problem and I am inclined to see this as a bug. Do you have any suggestions for how I should create my quarterly series from the pages one and two?

Re: Several observations per line

Posted: Fri Dec 21, 2012 8:27 am
by paues
While the bug report from my previous post still stands (it SHOULD be possible to execute the line "pagestruct name @date(year)" even if the YEAR series contains only one value), I have found an alternative approach which, while not as elegant, does the trick:

Code: Select all

for %pg one two pageselect {%pg} %original=@pagename for !i=1 to 4 pageselect {%original} pagecopy(page={%pg}q{!i}) alpha date=@str(year)+"q"+@str(!i) rename q{!i} q delete(noerr) q1 q2 q3 q4 next pageselect {%pg}q1 for !i=2 to 4 pageappend {%pg}q{!i} pagedelete {%pg}q{!i} next pageselect {%pg}q1 delete year pagestruct @date(date) name delete dateid pageunstack(page={%pg}series) name date pagestruct @date(date) delete q date dateid name rename q* * delete(noerr) obsid next

Re: Several observations per line

Posted: Fri Dec 21, 2012 11:37 am
by EViews Glenn
To be a valid panel structure in EViews you need two things:

1. The cross-section and within cross-section identifiers should jointly identify a unique observation.
2. There should be at least one cross-section with more than one observation.

The first is satisfied by your data, the second is not. Basically, the year dimension doesn't add identifying information so you have a data set that is more accurately classified as a cross-section workfile.

Now as your statement that it *should* be possible to classify this as a panel workfile. I am curious as to what the purpose of doing might be since there really isn't a panel.

Re: Several observations per line

Posted: Thu Jan 10, 2013 4:59 am
by paues
Please excuse my tardiness. I see that I might be somewhat oblivious regarding the panel concept. Maybe my problem would be solved if I included a series containing observation number? (I would try it myself, but I do not have access to EViews right now, as I am on leave.)