<?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: Reading a text file and maintaining format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373332#M89306</link>
    <description>I figured it out ( open a *.txt with Word pad which will be used always for&lt;BR /&gt;*.txt) then rename as *.ctl and everything works just fine.&lt;BR /&gt;&lt;BR /&gt;My program can then read the file.&lt;BR /&gt;&lt;BR /&gt;Thanks for the help.&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
    <pubDate>Wed, 05 Jul 2017 15:17:39 GMT</pubDate>
    <dc:creator>jacksonan123</dc:creator>
    <dc:date>2017-07-05T15:17:39Z</dc:date>
    <item>
      <title>Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373206#M89279</link>
      <description>&lt;P&gt;I have the following code which reads a text file (REF.txt) and changes the value at the &amp;amp;i.&amp;nbsp; The program works and changes the value but the output file (TEST) loses its format and is put out as continuous lines.&amp;nbsp; I have attached the file which I read in ref.ctl.&amp;nbsp; Can someone tell me how to edit my code so that it will read the ref.txt file and maintain the format in the outputted test1.txt etc files?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data _null_ ;&lt;BR /&gt;infile '/folders/myfolders/Bootconcer/REF.CTL' truncover;&lt;BR /&gt;/* INPUT CHARACTER FILE*/ &lt;BR /&gt;input c $10000.;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;do i=1 to 10;&lt;BR /&gt; myfile='/folders/myfolders/Bootconcer/REFS/TEST' || trim(left(put(i,9.))) ||  '.ctl';&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;file dummy filevar=myfile MOD ;&lt;BR /&gt; if _n_=2  then do;&lt;BR /&gt; if i=1 then do;&lt;BR /&gt;  amp_loc=index(c,'&amp;amp;');&lt;BR /&gt;    first_half=substr(c,1,amp_loc-1);&lt;BR /&gt;    last_half=substr(c,amp_loc+2);&lt;BR /&gt;	  end;&lt;BR /&gt; &lt;BR /&gt;   c= trim(first_half) || trim(left(put(i,9.))) || last_half;&lt;BR /&gt;    end;&lt;BR /&gt; &lt;BR /&gt;  put c $;&lt;BR /&gt; end;&lt;BR /&gt; run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 10:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373206#M89279</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2017-07-05T10:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373212#M89280</link>
      <description>&lt;P&gt;The&lt;/P&gt;
&lt;PRE&gt;/folders/myfolders&lt;/PRE&gt;
&lt;P&gt;tells me you are using SAS University Edition, right?&lt;/P&gt;
&lt;P&gt;This means that SAS runs on a UNIX (Linux), and the line separator will be a single '0a'x.&lt;/P&gt;
&lt;P&gt;DOS (Windows) programs expect a sequence of '0d0a'x as line separators, so it depends on which software you use to view the result files.&lt;/P&gt;
&lt;P&gt;Many editors (like notepad++) will display correctly and show UNIX in the status bar. Others will not be able to display the line changes, and you will see a continuous stream of characters.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 11:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373212#M89280</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-05T11:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373215#M89281</link>
      <description>When I use notepad the output is continuous but if I change the it to a&lt;BR /&gt;*.doc file it reads okay.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The problem is that when I use the extension.ctl which is the name I need to&lt;BR /&gt;use the file it reverts back to the continuous output.&lt;BR /&gt;&lt;BR /&gt;Yes I am using the University edition.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Is there another possible solution?&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 05 Jul 2017 11:46:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373215#M89281</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2017-07-05T11:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373219#M89283</link>
      <description>&lt;P&gt;Notepad is arguably the worst tool for dealing with text files that one can imagine. Discard it's use in favor of something usable like notepad++.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, to create DOS-compatible files, try to use the&lt;/P&gt;
&lt;PRE&gt;termstr=CRLF&lt;/PRE&gt;
&lt;P&gt;option in your file statement.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 11:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373219#M89283</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-05T11:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373222#M89286</link>
      <description>&lt;P&gt;Worth a try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change the logic that writes out the result this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put c;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, try it this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put _infile_ @ amp_loc i z2.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This would keep all characters in their original position, and place a two-digit version of i (with a leading zero if needed) where the ampersand appears.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 12:08:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373222#M89286</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-05T12:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373278#M89293</link>
      <description>Should this go on the infile or the my file statement?&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 05 Jul 2017 13:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373278#M89293</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2017-07-05T13:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373286#M89294</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44100"&gt;@jacksonan123&lt;/a&gt; wrote:&lt;BR /&gt;Should this go on the infile or the my file statement?&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;FILE statement, as it needs to influence your output. As it is, SAS produces correct output already, but certain non-UNIX software can't deal with it, do we need to make SAS write DOS-compatible output.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 14:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373286#M89294</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-05T14:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373290#M89295</link>
      <description>&lt;P&gt;I put that code in the infile statement and got the same results-see attached file.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 14:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373290#M89295</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2017-07-05T14:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373292#M89296</link>
      <description>I sent the file as an attachment and it looks okay but when I open it with&lt;BR /&gt;notepad there are no line breaks.&lt;BR /&gt;&lt;BR /&gt;I put in the suggested code and the results were the same.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 05 Jul 2017 14:12:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373292#M89296</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2017-07-05T14:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373297#M89298</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44100"&gt;@jacksonan123&lt;/a&gt; wrote:&lt;BR /&gt;When I use notepad the output is continuous but if I change the it to a&lt;BR /&gt;*.doc file it reads okay.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The problem is that when I use the extension.ctl which is the name I need to&lt;BR /&gt;use the file it reverts back to the continuous output.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Change the settings on your PC to always open *.cti files using WORDPAD instead of NOTEPAD. &amp;nbsp;That editor is not much different from notepad and it will properly edit files that use LF as the end of line characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 14:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373297#M89298</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-05T14:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373329#M89304</link>
      <description>Yes word pad works, but I can't find a *.ctl in my associate a file type or&lt;BR /&gt;protocol with a program choice list to connect to Word Pad.&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 05 Jul 2017 15:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373329#M89304</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2017-07-05T15:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373331#M89305</link>
      <description>Used to be in Windows you could right click on a file and selection Open With to tell it to open with a different program. There was a check box to say make this the default program.&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jul 2017 15:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373331#M89305</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-05T15:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a text file and maintaining format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373332#M89306</link>
      <description>I figured it out ( open a *.txt with Word pad which will be used always for&lt;BR /&gt;*.txt) then rename as *.ctl and everything works just fine.&lt;BR /&gt;&lt;BR /&gt;My program can then read the file.&lt;BR /&gt;&lt;BR /&gt;Thanks for the help.&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 05 Jul 2017 15:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-text-file-and-maintaining-format/m-p/373332#M89306</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2017-07-05T15:17:39Z</dc:date>
    </item>
  </channel>
</rss>

