<?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: Importing very long records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-very-long-records/m-p/44699#M9165</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The input statement is a very powerful parser.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With regards to reading single record.&amp;nbsp; Try something like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;data name;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; infile fileref lrecl=32767 length=len;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; input line $varying32767. len;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; run;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or you can assign the value of _INFILE_ to a character variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;data name;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; length line 32767;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; infile fileref lrecl=32767;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; input;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; line = _infile_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use a value less than 32767 if you like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll google json I don't know about that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 07 Aug 2011 22:38:26 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2011-08-07T22:38:26Z</dc:date>
    <item>
      <title>Importing very long records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-very-long-records/m-p/44698#M9164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm looking to import several text files which have a single observation and a single varaible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variables are between 14,000 and 22,000 characters in length (it's a data stream that I'm wanting to parse in SAS).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can only get the text file to import if I specify the exact length of the character string, e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lrecl=14,382 (in the infile statement)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; informat datvar $14382. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format datvar $14382. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input datvar $ 1-14382 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whilst this is fine for a single file, It's not possible to do this manual task for all of the files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please note that the datastream contains spaces so I'm having to specify it as a fixed width file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way of determining the length of the variable and loading this into a macro variable for use in the data step?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, has anyone written a json parser I could borrow!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Aug 2011 21:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-very-long-records/m-p/44698#M9164</guid>
      <dc:creator>FatCaptain</dc:creator>
      <dc:date>2011-08-07T21:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: Importing very long records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-very-long-records/m-p/44699#M9165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The input statement is a very powerful parser.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With regards to reading single record.&amp;nbsp; Try something like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;data name;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; infile fileref lrecl=32767 length=len;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; input line $varying32767. len;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; run;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or you can assign the value of _INFILE_ to a character variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;data name;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; length line 32767;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; infile fileref lrecl=32767;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; input;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; line = _infile_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use a value less than 32767 if you like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll google json I don't know about that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Aug 2011 22:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-very-long-records/m-p/44699#M9165</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-08-07T22:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Importing very long records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-very-long-records/m-p/44700#M9166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just add the TRUNCOVER option to your INFILE statement.&lt;/P&gt;&lt;P&gt;See this recent thread.&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://communities.sas.com/message/13199#13199"&gt;http://communities.sas.com/message/13199#13199&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Aug 2011 00:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-very-long-records/m-p/44700#M9166</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-08-08T00:44:25Z</dc:date>
    </item>
    <item>
      <title>Importing very long records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-very-long-records/m-p/44701#M9167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FatCaptain&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sounds like you might be planning to parse these data after they are loaded.&lt;/P&gt;&lt;P&gt;Have a look at some of the examples of the input statement. &lt;/P&gt;&lt;P&gt;I think that you might discover it to be even more powerful that the many parsing functions available in a data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could also read the data files as multiple pieces of, say, 64 bytes, like&lt;/P&gt;&lt;P&gt;data shorts;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile 'your file' recfm=F lrecl=64 pad ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input short $char64. ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2011 13:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-very-long-records/m-p/44701#M9167</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-08-09T13:36:20Z</dc:date>
    </item>
    <item>
      <title>Importing very long records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-very-long-records/m-p/44702#M9168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks Tom, I knew the answer was going to be a simple one! I was confusing missover with truncover and going nowhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks also Data _null_ and Peter.C.&lt;/P&gt;&lt;P&gt;I never thought about using the input statement to parse the character string. Looking at some of the options available, it will allow me to do most of the work before I use data steps to pretty things up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to admit that I'm too used to wizards handling data imports for me. Looks like this is as good an opportunity to get to grips with the finer points of coding imports instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2011 13:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-very-long-records/m-p/44702#M9168</guid>
      <dc:creator>FatCaptain</dc:creator>
      <dc:date>2011-08-10T13:45:57Z</dc:date>
    </item>
  </channel>
</rss>

