Several observations per line
Posted: Fri Aug 31, 2012 12:51 am
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:
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)