Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having trouble reading and parsing out an external file

Status
Not open for further replies.

Avalokit

Programmer
Sep 2, 2009
3
US
I am having trouble parsing out an external file that has observations that may or may not be continued on to the next line. Each row (i.e. observation) can have a variable amount of columns (i.e. variables) yet there are some consistent characteristics about the data.

These characteristics include:
- all observations begin in column 2; however, if they continue, the next line, the continued line, begins in column 1.
- the first variable of the observation can be valued a '-'
and in the example below it is the very last record.
- for observations that continue on the next line is there is an ' - ' as the last character string of the first line.
- any variable beginning with the string 'DATA(' and ending with the ')' can have a space delimited character string in between the "DATA(" & the ")". In this situation it should all considered as one charater string and 1 column.

I have a sample of the data records below:
----+----1----+----2----+----3----+----4----+----5----+----6
AAA.BBB-.- UID(ABCDCE**A) READ(A) WRITE(A) ALLOC(A)
BBB.CCC-.- UID(ABCDEF*****A123) READ(A) WRITE(A) -
EXEC(A)
CCC.DDD101.E3.- UID(ABCDEF*****ABCDEF) READ(A) -
WRITE(A) ALLOC(A) EXEC(A) DATA(FTP SERVER TO COL)
CCC.DDD101.E3.- UID(ABCDEF*****ABCDEF) READ(A) WRITE(A) -
ALLOC(A) EXEC(A)
AAA.BBB-.- UID(ABCDCE**A) READ(A) WRITE(A) DATA(FTP S1)
BBB.CCC-.- UID(ABCDEF*****A123) READ(A) WRITE(A) EXEC(A)
B1S.B1KA-.- UID(ASB1BP*****AB1KB1P) READ(A) EXEC(A)
B1S.B1KA-.- UID(ASB1BP*****AB1KB2P) READ(A) EXEC(A)
- UID(ABCDEF*****ABCDEF) READ(A) WRITE(A) ALLOC(A)

My goal would be to take the external file with all its variability and parse it out to a fixed length file. All the variable columns would be written to fixed width columns large enough to hold the data and all on one record. I am having trouble with SAS in doing this. I am relatively new to doing something like this with SAS but I know that it can be done. I have tried everything I can thing of to control the variability using missover, truncover, double trailing @, single trailing @, etc. but nothing that I've tried works.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top