<?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: Capture Linux command output into SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707648#M217295</link>
    <description>Thanks for the details and your valuable tips</description>
    <pubDate>Tue, 22 Dec 2020 12:33:07 GMT</pubDate>
    <dc:creator>Kaushik2</dc:creator>
    <dc:date>2020-12-22T12:33:07Z</dc:date>
    <item>
      <title>Capture Linux command output into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707457#M217217</link>
      <description>&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose I have a dataset "A" like below with variable called fname.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;fname&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;pgm1.sas&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;pgm2.sas&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I need a Linux command to be executed for every observation to the above dataset and &lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;capture output&lt;/STRONG&gt; &lt;/FONT&gt;in RESULT variable.&amp;nbsp; Lets say, I want to search for a word TERADATA in the programs. so, need to execute grep command for every observation and capture its Linux output&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;grep TERADATA pgm1.sas ,&lt;BR /&gt;grep TERADATA pgm2.sas&lt;/P&gt;&lt;P&gt;and so on...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So, my output dataset should look like :&lt;FONT color="#0000FF"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;fname&amp;nbsp;&lt;/FONT&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;RESULT&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;pgm1.sas&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;libname TERADATA "/abc/def";&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;pgm2.sas&amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;libname TERADATA "/xyz/";&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help. Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 14:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707457#M217217</guid>
      <dc:creator>Kaushik2</dc:creator>
      <dc:date>2020-12-21T14:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Capture Linux command output into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707499#M217229</link>
      <description>&lt;P&gt;Run a "dynamic pipe":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
fvar = catx(" ","grep",fname,'2&amp;gt;&amp;amp;1');
infile dummy pipe filevar=fvar truncover end=done;
do until (done);
  input response $100.;
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: see &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12477"&gt;@RichardDeVen&lt;/a&gt;&amp;nbsp;'s correction of the UNIX command.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 18:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707499#M217229</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-21T18:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Capture Linux command output into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707538#M217255</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;fvar = catx(" ","grep -i teradata",fname,'2&amp;gt;&amp;amp;1');&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Dec 2020 17:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707538#M217255</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-12-21T17:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Capture Linux command output into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707617#M217284</link>
      <description>&lt;P&gt;Thanks a lot&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12477"&gt;@RichardDeVen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am actually trying to prepare a prototype which can Read a SAS program along with its associated logs from a predefined folder and extract various details about program like datasets, filename, libraries used ,macro variables resolution (by Grep' command to access macro variable entry from log file) into a Excel spreadsheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hoping this prototype can serve as solution to Business Analysts kind of folks who may not be technologically adept but to get insights of a SAS program rather quickly.&amp;nbsp; I am halfway already but the excel report shows more of non-organized data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wanted to know if there are any such similar tools / program available which we can leverage?. Please advise.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 09:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707617#M217284</guid>
      <dc:creator>Kaushik2</dc:creator>
      <dc:date>2020-12-22T09:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Capture Linux command output into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707635#M217289</link>
      <description>&lt;P&gt;Have a look at &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=proc&amp;amp;docsetTarget=n05aazp6jtoup0n1qjee3h7jto24.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;PROC SCAPROC&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, IMO, you need to start up front. Before writing code, have a clear definition of requirements, and a design coming from that. Then, while you write the code, or IMMEDIATELY afterward, document what you have done.&lt;/P&gt;
&lt;P&gt;This documentation must include an exhaustive description of data going in and data coming out, making the program a "black box" where you do not have to look into to know what it does. This documentation will be the place where you direct your analysts for information.&lt;/P&gt;
&lt;P&gt;If you do not have such documentation at the moment, start creating it NOW. Your organization may already have a documentation framework in place, so integrate yours there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the introduction of Data Integration, SAS provides a complete framework for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keep in mind that 90% of a good coders work is coding, and another 90% documentation. See Maxim 16.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 11:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707635#M217289</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-22T11:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Capture Linux command output into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707648#M217295</link>
      <description>Thanks for the details and your valuable tips</description>
      <pubDate>Tue, 22 Dec 2020 12:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capture-Linux-command-output-into-SAS/m-p/707648#M217295</guid>
      <dc:creator>Kaushik2</dc:creator>
      <dc:date>2020-12-22T12:33:07Z</dc:date>
    </item>
  </channel>
</rss>

