<?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: .sh script to run the sas code in unix sas in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/90998#M25968</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have sas code which i run on the unix sas.. that code contains stage tables which needed to feed the data into target tables.&lt;/P&gt;&lt;P&gt;After i run the code i need to collect the statistics i mean the row count of 5 to 6 stage tables and need to send a text file from the with the row count to other server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The shell script should contain the sql statment with the select count(*) from table2 union all select count(*) from table2...... and it should generate txt file with current time stamp.&lt;/P&gt;&lt;P&gt;Some thing like this: test_current_timestamp.txt (text file)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls let me know if you have any queries!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;MVK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 24 Jun 2012 06:23:11 GMT</pubDate>
    <dc:creator>mvk_sas</dc:creator>
    <dc:date>2012-06-24T06:23:11Z</dc:date>
    <item>
      <title>.sh script to run the sas code in unix sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/90996#M25966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have sas code which i run in unix sas by using sas followed by the code name or program name ex: sas test.sas&lt;/P&gt;&lt;P&gt;Now i was asked to create a trigger file to run the&amp;nbsp; sas code on unix environment as it was running manually so far... script .sh .. i am not sure how to create the tirgger file could some help me on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The trigger file should have the current timestamp ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help really appriciated!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jun 2012 19:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/90996#M25966</guid>
      <dc:creator>mvk_sas</dc:creator>
      <dc:date>2012-06-23T19:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: .sh script to run the sas code in unix sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/90997#M25967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you mean by trigger file? Are you trying to trigger the SAS program when a file exists?&amp;nbsp; Or are you trying to write an output file when the SAS program runs?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jun 2012 19:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/90997#M25967</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-06-23T19:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: .sh script to run the sas code in unix sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/90998#M25968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have sas code which i run on the unix sas.. that code contains stage tables which needed to feed the data into target tables.&lt;/P&gt;&lt;P&gt;After i run the code i need to collect the statistics i mean the row count of 5 to 6 stage tables and need to send a text file from the with the row count to other server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The shell script should contain the sql statment with the select count(*) from table2 union all select count(*) from table2...... and it should generate txt file with current time stamp.&lt;/P&gt;&lt;P&gt;Some thing like this: test_current_timestamp.txt (text file)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls let me know if you have any queries!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;MVK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Jun 2012 06:23:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/90998#M25968</guid>
      <dc:creator>mvk_sas</dc:creator>
      <dc:date>2012-06-24T06:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: .sh script to run the sas code in unix sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/90999#M25969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is this what you are looking for...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%global nobs;&lt;/P&gt;&lt;P&gt;%macro test(dset=);&lt;/P&gt;&lt;P&gt;%let dsid=%sysfunc(open(sashelp.&amp;amp;dset.));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %if &amp;amp;dsid %then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let nobs=%sysfunc(attrn(&amp;amp;dsid,nobs));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let rc=%sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;data &amp;amp;dset;&lt;/P&gt;&lt;P&gt;count=&amp;amp;nobs;&lt;/P&gt;&lt;P&gt;table="&amp;amp;dset";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc append base=want data=&amp;amp;dset force;run;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;P&gt;%test(dset=adomsg);&lt;/P&gt;&lt;P&gt;%test(dset=adsmsg);&lt;/P&gt;&lt;P&gt;proc export data=want&lt;/P&gt;&lt;P&gt;outfile="F:\RD_output\want&amp;amp;sysdate..txt"&lt;/P&gt;&lt;P&gt;dbms=dlm; &lt;/P&gt;&lt;P&gt;delimiter=',';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Jun 2012 12:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/90999#M25969</guid>
      <dc:creator>shivas</dc:creator>
      <dc:date>2012-06-24T12:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: .sh script to run the sas code in unix sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/91000#M25970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not just modify the original program to write the txt file?&lt;/P&gt;&lt;P&gt;If not then create another program to write the txt file and call it after the first one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#!/bin/ksh&lt;/P&gt;&lt;P&gt;sas oldprogram&lt;/P&gt;&lt;P&gt;sas newprogram&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you really want to avoid creating a second file with the SAS code then look at the -stdio command line option. This will allow you to embed the SAS code into your script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you asking how to find out how many rows are in a table?&amp;nbsp; Are they SAS datasets or database tables?&lt;/P&gt;&lt;P&gt;If they are SAS datasets then you can query DICTIONARY.TABLES. If they are in a database then you might need to use a query to determine the number of rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Writing TXT files with SAS is trivial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; set counts;&lt;/P&gt;&lt;P&gt; file '&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;test_current_timestamp.txt' ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; put memname nobs;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use macro code or data step code and FILE statement options to generate a filename using date time. Or you could have the command script pass in the filename as run time parameter to the program.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Jun 2012 13:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/91000#M25970</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-06-24T13:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: .sh script to run the sas code in unix sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/91001#M25971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Guys for helping me out ... I have invoked bteq script to create a text file .. this solutions provided by all gave me some idea.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2012 17:01:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/91001#M25971</guid>
      <dc:creator>mvk_sas</dc:creator>
      <dc:date>2012-06-25T17:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: .sh script to run the sas code in unix sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/459991#M70290</link>
      <description>&lt;P&gt;1. Create a SAS program in a unix path - Eg. /opt/sas/Test.sas&lt;/P&gt;&lt;P&gt;2. Run the sas program using batch mode by create unix Script named as Test.sh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#! /bin/sh&lt;/P&gt;&lt;P&gt;/sas/config/Lev1/BatchServer/sasbatch.sh -log &lt;SPAN&gt;/opt/sas/TEST&lt;/SPAN&gt;_#Y.#m.#d_#H.#M.#s.log -noprint -batch -noterminal -logparm "rollover=session" -sysin /&lt;SPAN&gt;opt/sas/Test.sas&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;rc=$?&lt;/P&gt;&lt;P&gt;exit $rc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3.Execute the script unix UNix console or use systask command in SAS editor&amp;nbsp;&lt;/P&gt;&lt;P&gt;systask command "&lt;SPAN&gt;/opt/sas/Test.sh" shell wait;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4. Ensure the permissions are well defined the files created in Unix. Use chmod command&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ritesh&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 10:44:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sh-script-to-run-the-sas-code-in-unix-sas/m-p/459991#M70290</guid>
      <dc:creator>riteshfrank</dc:creator>
      <dc:date>2018-05-04T10:44:58Z</dc:date>
    </item>
  </channel>
</rss>

