<?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 Reading a program into SAS, losing indenting in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/308344#M66160</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I have a program like this...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*****************************************************&lt;/P&gt;
&lt;P&gt;THIS IS A TEST PROGRAM.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROJECT NUMBER: 123456&lt;/P&gt;
&lt;P&gt;*****************************************************;&lt;/P&gt;
&lt;P&gt;data a;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var1 = 'hello'; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;**************** end of program ****************;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;... and I want to read it into SAS to edit it with SAS, for example ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;** READ IN **;&lt;/P&gt;
&lt;P&gt;data tempa;&lt;BR /&gt;infile "U:\test_program_orig.sas" truncover ; &amp;nbsp; ** #1 **;&lt;BR /&gt; input line $500. ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;** EDIT **;&lt;/P&gt;
&lt;P&gt;data tempb;&lt;/P&gt;
&lt;P&gt;set tempa;&lt;/P&gt;
&lt;P&gt;if left(upcase(line)) =: 'PROJECT NUMBER' then line = ' Project Number: ' || '09'x || "234567";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;** OUTPUT **;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set tempb;&lt;/P&gt;
&lt;P&gt;file "&lt;SPAN&gt;U:\test_program_new.sas&lt;/SPAN&gt;";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;During the READ IN (#1) step, I lose all my indenting (like in the var1= 'hello' statement). &amp;nbsp;Is there an option to retain leading blanks?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 31 Oct 2016 18:17:10 GMT</pubDate>
    <dc:creator>evp000</dc:creator>
    <dc:date>2016-10-31T18:17:10Z</dc:date>
    <item>
      <title>Reading a program into SAS, losing indenting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/308344#M66160</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I have a program like this...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*****************************************************&lt;/P&gt;
&lt;P&gt;THIS IS A TEST PROGRAM.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROJECT NUMBER: 123456&lt;/P&gt;
&lt;P&gt;*****************************************************;&lt;/P&gt;
&lt;P&gt;data a;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var1 = 'hello'; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;**************** end of program ****************;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;... and I want to read it into SAS to edit it with SAS, for example ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;** READ IN **;&lt;/P&gt;
&lt;P&gt;data tempa;&lt;BR /&gt;infile "U:\test_program_orig.sas" truncover ; &amp;nbsp; ** #1 **;&lt;BR /&gt; input line $500. ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;** EDIT **;&lt;/P&gt;
&lt;P&gt;data tempb;&lt;/P&gt;
&lt;P&gt;set tempa;&lt;/P&gt;
&lt;P&gt;if left(upcase(line)) =: 'PROJECT NUMBER' then line = ' Project Number: ' || '09'x || "234567";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;** OUTPUT **;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set tempb;&lt;/P&gt;
&lt;P&gt;file "&lt;SPAN&gt;U:\test_program_new.sas&lt;/SPAN&gt;";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;During the READ IN (#1) step, I lose all my indenting (like in the var1= 'hello' statement). &amp;nbsp;Is there an option to retain leading blanks?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 18:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/308344#M66160</guid>
      <dc:creator>evp000</dc:creator>
      <dc:date>2016-10-31T18:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a program into SAS, losing indenting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/308345#M66161</link>
      <description>&lt;P&gt;Try&amp;nbsp;&lt;SPAN&gt;$char500&lt;/SPAN&gt;&lt;SPAN&gt;. as your informat.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 18:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/308345#M66161</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-10-31T18:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a program into SAS, losing indenting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/308346#M66162</link>
      <description>&lt;P&gt;Excellent. &amp;nbsp;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 18:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/308346#M66162</guid>
      <dc:creator>evp000</dc:creator>
      <dc:date>2016-10-31T18:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a program into SAS, losing indenting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/308352#M66165</link>
      <description>&lt;P&gt;You can do it all in one step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   infile cards;
   input;
   if left(upcase(_infile_)) =: 'PROJECT NUMBER' then _infile_ = ' Project Number: ' || '09'x || "234567";
   file log;
   put _infile_;
   cards4;
*****************************************************
THIS IS A TEST PROGRAM.&amp;nbsp;
PROJECT NUMBER: 123456
*****************************************************;
data a;
&amp;nbsp; &amp;nbsp; &amp;nbsp;var1 = 'hello'; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;
run;
**************** end of program ****************;
;;;;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;25         data _null_;
26            infile cards;
27            input;
28            if left(upcase(_infile_)) =: 'PROJECT NUMBER' then _infile_ = ' Project Number: ' || '09'x || "234567";
29            file log;
30            put _infile_;
31            cards4;

*****************************************************                           
THIS IS A TEST PROGRAM.&amp;nbsp;                                                        
 Project Number: 	234567
*****************************************************;                          
data a;                                                                         
&amp;nbsp; &amp;nbsp; &amp;nbsp;var1 = 'hello'; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;                                                     
run;                                                                            
**************** end of program ****************;  &lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2016 19:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/308352#M66165</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-10-31T19:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a program into SAS, losing indenting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/327091#M72937</link>
      <description>&lt;P&gt;Follow-up to this...&lt;/P&gt;
&lt;P&gt;The CHARxx. format gives you lines with lots of trailing blanks. &amp;nbsp;I discovered that VARYING works well to avoid that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eol = findc(line, ' ' ,'v', -200); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* end of line: v -&amp;gt; find first non-blank, -200 -&amp;gt; R to L *; &lt;BR /&gt; if eol = 0 then eol = 1;&lt;BR /&gt; put line $varying200. eol;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Someone might find this useful.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/327091#M72937</guid>
      <dc:creator>evp000</dc:creator>
      <dc:date>2017-01-24T15:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a program into SAS, losing indenting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/327102#M72944</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/6791"&gt;@evp000&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Follow-up to this...&lt;/P&gt;
&lt;P&gt;The CHARxx. format gives you lines with lots of trailing blanks. &amp;nbsp;I discovered that VARYING works well to avoid that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eol = findc(line, ' ' ,'v', -200); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* end of line: v -&amp;gt; find first non-blank, -200 -&amp;gt; R to L *; &lt;BR /&gt; if eol = 0 then eol = 1;&lt;BR /&gt; put line $varying200. eol;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Someone might find this useful.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might consider the LENGTH function for finding the length of a character variable.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 16:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/327102#M72944</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-01-24T16:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a program into SAS, losing indenting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/327105#M72945</link>
      <description>&lt;P&gt;Length takes off the leading blanks and I want to keep them.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 16:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/327105#M72945</guid>
      <dc:creator>evp000</dc:creator>
      <dc:date>2017-01-24T16:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a program into SAS, losing indenting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/327107#M72946</link>
      <description>&lt;P&gt;Oh, no it doesn't get rid of the leading blanks, so ya, that would work too. &amp;nbsp;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 16:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-program-into-SAS-losing-indenting/m-p/327107#M72946</guid>
      <dc:creator>evp000</dc:creator>
      <dc:date>2017-01-24T16:46:42Z</dc:date>
    </item>
  </channel>
</rss>

