<?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 Re: Load .txt file and reclen in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Load-txt-file-and-reclen/m-p/123622#M33972</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without example data it is difficult to provide a working suggestion.&amp;nbsp; You can use the infile option "length=" to specify a variable, in your infile statement, that will capture each record's length (e.g., infile "c:\mydata.txt" length=reclen).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That way you can create both files in one pass.&amp;nbsp; e.g., pseudo code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data long short;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile "c:\mydata.txt" length=reclen;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input variable $varying500.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if reclen gt 200 then output long;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else output short;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Feb 2013 14:20:36 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2013-02-28T14:20:36Z</dc:date>
    <item>
      <title>Load .txt file and reclen</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Load-txt-file-and-reclen/m-p/123620#M33970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to load a .txt file into SAS, and have created two separate load files. One that looks at variable1A and the other, variable 1B. However, both variable1A and variable1B are in the same .txt file. The only way to separate the two is that variable 1A has a shorter record length than variable 1B. Is there a way to load the file so that only those records with variable1A (with say a maximum record length of 200) are in one SAS dataset, and then those variables with a reclen that exceed 200 are in another SAS dataset?&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2013 14:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Load-txt-file-and-reclen/m-p/123620#M33970</guid>
      <dc:creator>AshleyM</dc:creator>
      <dc:date>2013-02-28T14:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Load .txt file and reclen</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Load-txt-file-and-reclen/m-p/123621#M33971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes.&amp;nbsp; Use the LENGTH option in the INFILE statement.&amp;nbsp; Example 4 in the reference documentation may be helpful&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#n1rill4udj0tfun1fvce3j401plo.htm" title="http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#n1rill4udj0tfun1fvce3j401plo.htm"&gt;SAS(R) 9.3 Statements: Reference&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general, something like this might work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FILENAME indata 'mydata.txt' LENGTH=linelen;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA A B;&lt;/P&gt;&lt;P&gt;INFILE indata;&lt;/P&gt;&lt;P&gt;INPUT &amp;lt;whatever&amp;gt;;&lt;/P&gt;&lt;P&gt;IF linelen=&amp;lt;onevalue&amp;gt; then output a;&lt;/P&gt;&lt;P&gt;ELSE IF linelen=&amp;lt;othervalue&amp;gt; THEN OUTPUT b;&lt;/P&gt;&lt;P&gt;ELSE &amp;lt;put error message&amp;gt;;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2013 14:18:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Load-txt-file-and-reclen/m-p/123621#M33971</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2013-02-28T14:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Load .txt file and reclen</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Load-txt-file-and-reclen/m-p/123622#M33972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without example data it is difficult to provide a working suggestion.&amp;nbsp; You can use the infile option "length=" to specify a variable, in your infile statement, that will capture each record's length (e.g., infile "c:\mydata.txt" length=reclen).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That way you can create both files in one pass.&amp;nbsp; e.g., pseudo code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data long short;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile "c:\mydata.txt" length=reclen;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input variable $varying500.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if reclen gt 200 then output long;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else output short;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2013 14:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Load-txt-file-and-reclen/m-p/123622#M33972</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-02-28T14:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Load .txt file and reclen</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Load-txt-file-and-reclen/m-p/123623#M33973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ashley,&amp;nbsp; it would be helpful to know how you are reading in the text file.&amp;nbsp; Can you do a simple length statement on both 1A and 1B then compare the lengths?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data short(keep=1A)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; long(keep=1B);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set beginning;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; a=length(1A);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; b=length(1B);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (a &amp;lt; b) or (a&amp;lt;200) then output short;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (b &amp;gt; a) or (b&amp;gt;200) then output long;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2013 14:23:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Load-txt-file-and-reclen/m-p/123623#M33973</guid>
      <dc:creator>bwasicak</dc:creator>
      <dc:date>2013-02-28T14:23:04Z</dc:date>
    </item>
  </channel>
</rss>

