<?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: read a text file character by character on the fly in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565656#M158841</link>
    <description>Perhaps with TRANWRD() function since this is inserting an extra character.&lt;BR /&gt;</description>
    <pubDate>Wed, 12 Jun 2019 19:42:17 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-06-12T19:42:17Z</dc:date>
    <item>
      <title>read a text file character by character on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565559#M158811</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;im trying to read a large non delimited text file into a dataset. Im using PC SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The file is the document.xml part from a docx file. It does not seem to be possible to read it into one variable and one row in a dataset since it is too large (&amp;gt;300kb). I was thinking that one way of doing this is to pre process the file by reading it character by character and add a&amp;nbsp; CR (carriage return) every time i see a '&amp;gt;'. Then output it and re-read it by using proc import with CR ('0D0A'x) as a delimiter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can this be done. If yes then how?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Jan&lt;/P&gt;&lt;P&gt;p.s. note that reading the file with a XML libname is not useful here.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 13:55:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565559#M158811</guid>
      <dc:creator>janpeter</dc:creator>
      <dc:date>2019-06-12T13:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: read a text file character by character on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565598#M158821</link>
      <description>What happens if you do try to read it in as one string?&lt;BR /&gt;&lt;BR /&gt;data test;&lt;BR /&gt;infile 'path to xml' lrecl=32000;&lt;BR /&gt;input;&lt;BR /&gt;length x $32000.;&lt;BR /&gt;x=_infile_;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 12 Jun 2019 15:30:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565598#M158821</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-12T15:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: read a text file character by character on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565606#M158823</link>
      <description>&lt;P&gt;Not sure if it will help but here is how to do what you asked.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename in 'document.xml';
filename out 'document_fixed.xml';

data _null_;
  infile in recfm=n;
  file out recfm=n;
  input char $char1. ;
  put char $char1. ;
  if char='&amp;gt;' then put '0D'x;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't think that UTF-8 (or other multibyte character sets) would make any difference.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 15:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565606#M158823</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-12T15:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: read a text file character by character on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565613#M158825</link>
      <description>If you remind me later, I did this parsing out a Word doc before. If that's what you're trying to do by the way, I ended up using a python library instead (called from SAS) that worked very well to parse the contents from word documents.But I can dig out the code I had been working with at least.</description>
      <pubDate>Wed, 12 Jun 2019 16:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565613#M158825</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-12T16:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: read a text file character by character on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565623#M158827</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;that certainly did the trick. Thanks a lot!&lt;/P&gt;&lt;P&gt;Yes. I was considering Python as an option but prefer to keep it all in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Jan&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 17:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565623#M158827</guid>
      <dc:creator>janpeter</dc:creator>
      <dc:date>2019-06-12T17:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: read a text file character by character on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565624#M158828</link>
      <description>&lt;P&gt;Sorry i was too fast. I of course meant to write Tom&lt;/P&gt;&lt;P&gt;Thanks Tom!!!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;J&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 17:11:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565624#M158828</guid>
      <dc:creator>janpeter</dc:creator>
      <dc:date>2019-06-12T17:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: read a text file character by character on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565652#M158839</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Not sure if it will help but here is how to do what you asked.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename in 'document.xml';
filename out 'document_fixed.xml';

data _null_;
  infile in recfm=n;
  file out recfm=n;
  input char $char1. ;
  put char $char1. ;
  if char='&amp;gt;' then put '0D'x;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't think that UTF-8 (or other multibyte character sets) would make any difference.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I wonder if it would be faster to read the file as if were fixed length and apply TRANSLATE function to _INFILE_. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 19:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565652#M158839</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-06-12T19:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: read a text file character by character on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565656#M158841</link>
      <description>Perhaps with TRANWRD() function since this is inserting an extra character.&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Jun 2019 19:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-a-text-file-character-by-character-on-the-fly/m-p/565656#M158841</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-12T19:42:17Z</dc:date>
    </item>
  </channel>
</rss>

