<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Parsing the Unformatted Raw data file to create a SAS Dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Parsing-the-Unformatted-Raw-data-file-to-create-a-SAS-Dataset/m-p/75142#M21787</link>
    <description>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.&lt;BR /&gt;
&lt;BR /&gt;
For eample one row is as below:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;&lt;I&gt;03ABW&lt;/I&gt;&lt;/B&gt;123456789Firstname                          MA                                 lastname                           JR  111111111125      Y23456789019850121emailid@email.com  &lt;BR /&gt;
&lt;BR /&gt;
The first 5 characters are the segment Identifier is "03ABW".    &lt;BR /&gt;
Next 9 digits are SSN.&lt;BR /&gt;
Next 35 chars are First Name&lt;BR /&gt;
Next 35 chars are Middle Name&lt;BR /&gt;
Next 35 chars are Last  Name&lt;BR /&gt;
Next 4  chars are Generation&lt;BR /&gt;
And so on..&lt;BR /&gt;
&lt;BR /&gt;
For creating the data set with the following fileds &lt;BR /&gt;
SSN  $9&lt;BR /&gt;
First Name $35&lt;BR /&gt;
Middle Name $35&lt;BR /&gt;
Last Name $35&lt;BR /&gt;
...&lt;BR /&gt;
&lt;BR /&gt;
I am using the following&lt;BR /&gt;
&lt;BR /&gt;
DATA NAME&lt;BR /&gt;
INFILE '/home/xxx/NAME.txt';&lt;BR /&gt;
  &lt;BR /&gt;
  INPUT @'03ABW' Applicant_SSN $9&lt;BR /&gt;
        +1  APP_FIRST_NAME $35 ;    &lt;BR /&gt;
&lt;BR /&gt;
I am using the segment ID '03ABW'  to go the correct row. &lt;BR /&gt;
1) How do I go to different rows in the raw data file ?&lt;BR /&gt;
2) How do I to the adjacent columns in a row to get the SSN/Names etc. &lt;BR /&gt;
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</description>
    <pubDate>Wed, 14 Apr 2010 00:47:29 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-04-14T00:47:29Z</dc:date>
    <item>
      <title>Parsing the Unformatted Raw data file to create a SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Parsing-the-Unformatted-Raw-data-file-to-create-a-SAS-Dataset/m-p/75142#M21787</link>
      <description>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.&lt;BR /&gt;
&lt;BR /&gt;
For eample one row is as below:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;&lt;I&gt;03ABW&lt;/I&gt;&lt;/B&gt;123456789Firstname                          MA                                 lastname                           JR  111111111125      Y23456789019850121emailid@email.com  &lt;BR /&gt;
&lt;BR /&gt;
The first 5 characters are the segment Identifier is "03ABW".    &lt;BR /&gt;
Next 9 digits are SSN.&lt;BR /&gt;
Next 35 chars are First Name&lt;BR /&gt;
Next 35 chars are Middle Name&lt;BR /&gt;
Next 35 chars are Last  Name&lt;BR /&gt;
Next 4  chars are Generation&lt;BR /&gt;
And so on..&lt;BR /&gt;
&lt;BR /&gt;
For creating the data set with the following fileds &lt;BR /&gt;
SSN  $9&lt;BR /&gt;
First Name $35&lt;BR /&gt;
Middle Name $35&lt;BR /&gt;
Last Name $35&lt;BR /&gt;
...&lt;BR /&gt;
&lt;BR /&gt;
I am using the following&lt;BR /&gt;
&lt;BR /&gt;
DATA NAME&lt;BR /&gt;
INFILE '/home/xxx/NAME.txt';&lt;BR /&gt;
  &lt;BR /&gt;
  INPUT @'03ABW' Applicant_SSN $9&lt;BR /&gt;
        +1  APP_FIRST_NAME $35 ;    &lt;BR /&gt;
&lt;BR /&gt;
I am using the segment ID '03ABW'  to go the correct row. &lt;BR /&gt;
1) How do I go to different rows in the raw data file ?&lt;BR /&gt;
2) How do I to the adjacent columns in a row to get the SSN/Names etc. &lt;BR /&gt;
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</description>
      <pubDate>Wed, 14 Apr 2010 00:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Parsing-the-Unformatted-Raw-data-file-to-create-a-SAS-Dataset/m-p/75142#M21787</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-14T00:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing the Unformatted Raw data file to create a SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Parsing-the-Unformatted-Raw-data-file-to-create-a-SAS-Dataset/m-p/75143#M21788</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
Sounds like a hierarchical data structure (mainframe?).&lt;BR /&gt;
&lt;BR /&gt;
The following code example assumes that there are always 2 records of raw data which make up a SAS observation.&lt;BR /&gt;
&lt;BR /&gt;
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).&lt;BR /&gt;
&lt;BR /&gt;
data demo;&lt;BR /&gt;
  infile datalines truncover;&lt;BR /&gt;
  retain var1 var2;&lt;BR /&gt;
  input Segment $ 1-2 ID $ 3-5 @;&lt;BR /&gt;
  if segment='01' then&lt;BR /&gt;
  do;&lt;BR /&gt;
    input var1 6-12;&lt;BR /&gt;
  end;&lt;BR /&gt;
  else&lt;BR /&gt;
  if segment='02' then &lt;BR /&gt;
  do;&lt;BR /&gt;
    input var2 6-12;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
01ABW12&lt;BR /&gt;
02ABW13&lt;BR /&gt;
01AEW234&lt;BR /&gt;
02AEW245&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=demo;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Sun, 18 Apr 2010 12:21:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Parsing-the-Unformatted-Raw-data-file-to-create-a-SAS-Dataset/m-p/75143#M21788</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-04-18T12:21:58Z</dc:date>
    </item>
  </channel>
</rss>

