Reading fixed width data
Posted: Thu Aug 11, 2011 7:13 am
I'm trying to figure out how to read in some data that is in fixed-width format.
Here is short extract from the dataset (note that data for ST, CD, and REG should be right-aligned on columns 2, 4, and 8 respectively - but I can't seem to get it to show that way here):
I tried using the rformat statement in the wfopen command (with options type=raw and fieldtype=fixed) but received syntax error message of "unexpected character '(' in rformat specification." According to the documentation, aren't you supposed to enclose your rformat specification within parentheses?
Anyway, how would you suggest that I phrase my wfopen command to read this raw data into a workfile?
Here is short extract from the dataset (note that data for ST, CD, and REG should be right-aligned on columns 2, 4, and 8 respectively - but I can't seem to get it to show that way here):
Code: Select all
STCD REG DIVISION NAME POPULATION POP WT
1 1 6 NORTHERN VALLEY 657744 0.1479
2 5 8 SOUTHWEST 179964 0.0351
3 8 7 SOUTH CENTRAL 172053 0.0644
4 1 9 NORTH COAST 1261635 0.0372
5 3 8 NORTH DRAINAGE BASIN 29783 0.0069
6 2 1 CENTRAL 2029652 0.5960
7 1 5 NORTHERN 465853 0.5945
8 6 5 LOWER EAST COAST 4903143 0.3068
9 4 5 WEST CENTRAL 1248322 0.1525
1010 8 EASTERN HIGHLANDS 131750 0.1018
11 1 3 NORTHWEST 765271 0.0616
12 6 3 EAST CENTRAL 342095 0.0562
Anyway, how would you suggest that I phrase my wfopen command to read this raw data into a workfile?