<?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 Importing fixed column text file multiple fixed columns criteria in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-fixed-column-text-file-multiple-fixed-columns-criteria/m-p/447832#M112573</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a plain text file I would like to import into SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is a fixed column text file, however there are multiple fixed lengths depending on the type of record.&lt;/P&gt;&lt;P&gt;Notes&lt;/P&gt;&lt;P&gt;1.)&amp;nbsp; The type of record is indicated by the first number in each length&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -I.E Records that start with 1: Store Indicator&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Lines 1 - 10 Record ID, 11-15 Store Name etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Records that start with 4: Transaction Indicator&amp;nbsp; &amp;nbsp; &amp;nbsp; Lines 1- 15&amp;nbsp; FirstName, 15-30 Last Name etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Records that start with 4 flows over into 2 lines for every record&lt;/P&gt;&lt;P&gt;2.)&amp;nbsp; &amp;nbsp;Each group of Transactions are separated by a Store Record, however, they vary in then number of transactions&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-I.E. Store Name (Records that start with 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;space&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Transaction Record #1(Records that start with 4)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Transaction Record #1 Continued&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Transaction Record #2( Records that start with 4)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Transaction Record #2&amp;nbsp; Continued&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Closing Line (Records that start with 6)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;space&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;New Store Name Record(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Transaction Records (4)- Varying #'s&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Closing Line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached a sample text file in a similar format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I import a file like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Mar 2018 15:43:30 GMT</pubDate>
    <dc:creator>jackx</dc:creator>
    <dc:date>2018-03-22T15:43:30Z</dc:date>
    <item>
      <title>Importing fixed column text file multiple fixed columns criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-fixed-column-text-file-multiple-fixed-columns-criteria/m-p/447832#M112573</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a plain text file I would like to import into SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is a fixed column text file, however there are multiple fixed lengths depending on the type of record.&lt;/P&gt;&lt;P&gt;Notes&lt;/P&gt;&lt;P&gt;1.)&amp;nbsp; The type of record is indicated by the first number in each length&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -I.E Records that start with 1: Store Indicator&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Lines 1 - 10 Record ID, 11-15 Store Name etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Records that start with 4: Transaction Indicator&amp;nbsp; &amp;nbsp; &amp;nbsp; Lines 1- 15&amp;nbsp; FirstName, 15-30 Last Name etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Records that start with 4 flows over into 2 lines for every record&lt;/P&gt;&lt;P&gt;2.)&amp;nbsp; &amp;nbsp;Each group of Transactions are separated by a Store Record, however, they vary in then number of transactions&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-I.E. Store Name (Records that start with 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;space&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Transaction Record #1(Records that start with 4)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Transaction Record #1 Continued&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Transaction Record #2( Records that start with 4)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Transaction Record #2&amp;nbsp; Continued&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Closing Line (Records that start with 6)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;space&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;New Store Name Record(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Transaction Records (4)- Varying #'s&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Closing Line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached a sample text file in a similar format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I import a file like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 15:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-fixed-column-text-file-multiple-fixed-columns-criteria/m-p/447832#M112573</guid>
      <dc:creator>jackx</dc:creator>
      <dc:date>2018-03-22T15:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Importing fixed column text file multiple fixed columns criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-fixed-column-text-file-multiple-fixed-columns-criteria/m-p/447840#M112574</link>
      <description>&lt;P&gt;You don't import it.&amp;nbsp; You have to write a program.&amp;nbsp; The overall form of the program is to read in the record type, without releasing the current line of data.&amp;nbsp; Depending on the record type, read in the appropriate variables.&amp;nbsp; It's actually more complex than that, because&amp;nbsp; you have to decide what the final data set should look like.&amp;nbsp; Most likely, you will end up repeating the store-level information for each transaction.&amp;nbsp; In that case, the overall form of the program would look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;infile myfile;&lt;/P&gt;
&lt;P&gt;input&amp;nbsp;record_type $1 @;&lt;/P&gt;
&lt;P&gt;if record_type='1' then input record_id $ 1-10 store_name $ 11-15 ..........;&lt;/P&gt;
&lt;P&gt;retain store_name;&lt;/P&gt;
&lt;P&gt;else if record_type='4' then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; input FirstName $ 1-15 LastName $ ........................;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 16:19:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-fixed-column-text-file-multiple-fixed-columns-criteria/m-p/447840#M112574</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-22T16:19:22Z</dc:date>
    </item>
  </channel>
</rss>

