I have to read a raw data file which has multiple rows. Each row has different data and identified by first 5 characters. Each row has to be parsed and stored to SAS Dataset.
For eample one row is as below:
03ABW123456789Firstname MA lastname JR 111111111125 Y23456789019850121emailid@email.com
The first 5 characters are the segment Identifier is "03ABW".
Next 9 digits are SSN.
Next 35 chars are First Name
Next 35 chars are Middle Name
Next 35 chars are Last Name
Next 4 chars are Generation
And so on..
For creating the data set with the following fileds
First Name $35
Middle Name $35
Last Name $35
I am using the segment ID '03ABW' to go the correct row.
1) How do I go to different rows in the raw data file ?
2) How do I to the adjacent columns in a row to get the SSN/Names etc.
3) How do I move by a specified displacement and get that data from INPUT statement to populate in the dataset fields?
Message was edited by: MR
Sounds like a hierarchical data structure (mainframe?).
The following code example assumes that there are always 2 records of raw data which make up a SAS observation.
This is most likely not how your raw dataset structure looks like but it should give you the idea. The most important thing is the '@' used in the input statement (there is also an '@@' - look it up in the doc).
infile datalines truncover;
retain var1 var2;
input Segment $ 1-2 ID $ 3-5 @;
if segment='01' then
input var1 6-12;
if segment='02' then
input var2 6-12;