<?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: Trying read SAS program and store it in the DATASET. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/904055#M357195</link>
    <description>&lt;P&gt;Yet another way, with getting the buffer:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename rd 'C:\SAS_PACKAGES_DEV\SPFinit.sas';

data temp;
  infile rd;
  input;
  length rec $ 256;
  rec = _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Tue, 21 Nov 2023 07:40:11 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2023-11-21T07:40:11Z</dc:date>
    <item>
      <title>Trying read SAS program and store it in the DATASET.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/903884#M357132</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying reading&amp;nbsp; the entire SAS&amp;nbsp; program (.sas files) and storing entire program code in the dataset using option filename statement, but here problem is it is not able to fetch all lines of code instead fetching few lines. Can anyone please help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code:&lt;/P&gt;&lt;P&gt;filename rd 'C:\Users\rakes\Documents\My SAS Files\sas_practice\program_2.sas';&lt;/P&gt;&lt;P&gt;data temp;&lt;BR /&gt;infile rd;&lt;BR /&gt;input rec $150.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rakesh.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 11:11:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/903884#M357132</guid>
      <dc:creator>u63406443</dc:creator>
      <dc:date>2023-11-20T11:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Trying read SAS program and store it in the DATASET.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/903888#M357133</link>
      <description>&lt;P&gt;Why do you want to do this? Programs are stored best in their text form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The default value for an overflow while reading an external file is MISSOVER, so any line shorter than 150 characters will cause a missing value.&lt;/P&gt;
&lt;P&gt;Change your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
infile "C:\Users\rakes\Documents\My SAS Files\sas_practice\program_2.sas" truncover;
input rec $150.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since you seem to get &lt;EM&gt;some&lt;/EM&gt; lines with your original code, you may have to increase the informat, and also set a proper LRECL= option in the INFILE statement.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 11:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/903888#M357133</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-11-20T11:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Trying read SAS program and store it in the DATASET.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/903889#M357134</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename rd 'C:\temp\a.sas';

data temp;
infile rd length=len;
input rec $varying200. len;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Nov 2023 11:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/903889#M357134</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-11-20T11:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Trying read SAS program and store it in the DATASET.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/904047#M357190</link>
      <description>&lt;P&gt;Hi Kurt_Bremser,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need below program, because I merging almost 60 SAS codes, and filtering with a condition. I truly appreciate the update; it's been quite useful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you Kurt_Bremser&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 05:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/904047#M357190</guid>
      <dc:creator>u63406443</dc:creator>
      <dc:date>2023-11-21T05:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Trying read SAS program and store it in the DATASET.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/904048#M357191</link>
      <description>&lt;P&gt;Thank you Ksharp.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 05:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/904048#M357191</guid>
      <dc:creator>u63406443</dc:creator>
      <dc:date>2023-11-21T05:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: Trying read SAS program and store it in the DATASET.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/904052#M357193</link>
      <description>&lt;P&gt;If this is for some sort of impact analysis like to find all programs that use a certain table:&lt;/P&gt;
&lt;P&gt;I used to use Atom for such tasks but this tool got unfortunately depreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could still use Notepad++ to search through all .sas programs under a folder or even folder and sub-folders&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1700549266340.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90070iC60E515DE6FBC729/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1700549266340.png" alt="Patrick_0-1700549266340.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or for files under Linux/Rhel a grep command is often fit for purpose - potentially in combination with a find command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to use SAS for such a search then you could use the infile statement with a wildcard which would allow to write code that reads all .sas files in a folder in one go.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 06:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/904052#M357193</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-11-21T06:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Trying read SAS program and store it in the DATASET.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/904055#M357195</link>
      <description>&lt;P&gt;Yet another way, with getting the buffer:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename rd 'C:\SAS_PACKAGES_DEV\SPFinit.sas';

data temp;
  infile rd;
  input;
  length rec $ 256;
  rec = _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 07:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/904055#M357195</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-21T07:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Trying read SAS program and store it in the DATASET.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/904116#M357212</link>
      <description>&lt;P&gt;Because you used the default FLOWOVER setting for the INFILE statement when you tried to read past the end of a line SAS went to the next line to find the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's use an example using in-line data (requires informat longer than 80 since in-line data is padded to next multiple of 80 column card image).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input line $100.;
cards4;
line one
line two
line three
line four
line five
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1700579803754.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90076i1F61F883AC7DE09F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1700579803754.png" alt="Tom_0-1700579803754.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You want to use the TRUNCOVER option.&lt;/P&gt;
&lt;P&gt;You also want to use $CHAR informat to preserve any leading spaces on the lines.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  infile cards truncover;
  input line $char100.;
cards4;
filename rd 'C:\Users\rakes\Documents\My SAS Files\sas_practice\program_2.sas';

data temp;
  infile rd;
  input rec $150.;
run;

;;;;


proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt; Obs    line

 1     filename rd 'C:\Users\rakes\Documents\My SAS Files\sas_practice\program_2.sas';
 2
 3     data temp;
 4       infile rd;
 5       input rec $150.;
 6     run;
 7



&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Nov 2023 15:20:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-read-SAS-program-and-store-it-in-the-DATASET/m-p/904116#M357212</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-21T15:20:20Z</dc:date>
    </item>
  </channel>
</rss>

