<?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: Unix: passing parameter to a SAS program in command line in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368374#M87852</link>
    <description>&lt;P&gt;The -sysparm in you question should work, &amp;nbsp;you can pass multiple parameters in -sysparm option and parse it using scan function in sas file. To redirect your log and lst result to particular file you can use -log and -print options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Modifying your code as below:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;sas /&amp;lt;path&amp;gt;/&amp;lt;program&amp;gt;.sas -sysparm "value1,value2"&lt;/EM&gt; -log anypath/anyname.log -print anypath/anyname.lst&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in your code you can parse -sysparm using scan function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null;&lt;/P&gt;
&lt;P&gt;_value1=scan(sysparm(),1,', ');&lt;BR /&gt;_value2=scan(sysparm(),2,',');&lt;BR /&gt;&amp;nbsp;call symput("value1", "_value1");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;call symput("value2", "_value2");&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Jun 2017 16:14:21 GMT</pubDate>
    <dc:creator>nbonda</dc:creator>
    <dc:date>2017-06-19T16:14:21Z</dc:date>
    <item>
      <title>Unix: passing parameter to a SAS program in command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/367837#M87630</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to pass a parameters for a SAS code that is executed on command line (using crontab).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've just tried the following options but nothing happens:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;sas /&amp;lt;path&amp;gt;/&amp;lt;program&amp;gt;.sas -set p1 value1 -set p2 value2&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;sas /&amp;lt;path&amp;gt;/&amp;lt;program&amp;gt;.sas -sysparm "p1=value1,p2=value2"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Inside the &lt;EM&gt;&amp;lt;program&amp;gt;.sas&lt;/EM&gt; I use proc printto to redirect the log. When running only&amp;nbsp;&lt;EM&gt;sas /&amp;lt;path&amp;gt;/&amp;lt;program&amp;gt;.sas &lt;/EM&gt;the program execute and generate the corresponding SAS log. When trying to execute the "-set" version or "-sysparm" version, SAS log file is not generated and nothing happen.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea what's going on? I'm executing on Unix (HP-UX) and with SAS 9.2 TSM2 version,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 18:06:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/367837#M87630</guid>
      <dc:creator>MariaD</dc:creator>
      <dc:date>2017-06-16T18:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Unix: passing parameter to a SAS program in command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/367921#M87652</link>
      <description>&lt;P&gt;On a Unix command the options come before the arguments.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sas  -set p1 value1 -set p2 value2 /&amp;lt;path&amp;gt;/&amp;lt;program&amp;gt;.sas&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also use the -sysin option to specify the program name, but I am not sure why anyone would use that.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2017 01:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/367921#M87652</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-17T01:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Unix: passing parameter to a SAS program in command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/367934#M87660</link>
      <description>&lt;P&gt;If you have lots of parameters to pass, use environment variables:&lt;/P&gt;
&lt;P&gt;(shell script)&lt;/P&gt;
&lt;PRE&gt;export VAR1=val1
export VAR2=val2
/sasconf/Lev1/SASApp/BatchServer/sasbatch.sh /path/program.sas&lt;/PRE&gt;
&lt;P&gt;(program)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let var1=%sysget(VAR1);
%let var2=%sysget(VAR2);

/* code */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This keeps the SAS commandline clean. Use it to pass configuration options, not program parameters.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2017 07:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/367934#M87660</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-17T07:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Unix: passing parameter to a SAS program in command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368030#M87704</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/36451"&gt;@MariaD&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Besides of -SET which creates OS environment variables you can also use option -INITSTMT and then have a few %LET statements which create macro variables which you can use directly in your code.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lesysoptsref/69799/HTML/default/viewer.htm#n16z79lqkz4a87n1urzo6mithnza.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lesysoptsref/69799/HTML/default/viewer.htm#n16z79lqkz4a87n1urzo6mithnza.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I normally prefer to implement a permanent parameter table and then call this table from my code. This allows me to see everything that's going on directly in the code and also to change parameter values in data instead of having to change code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tend to use &lt;EM&gt;sas.sh&lt;/EM&gt; for batch commands as this will invoke the full application&amp;nbsp;server specific environment with all the .cfg's and autoexec's I've used for developing my code (i.e. .../Config/Lev1/SASApp/sas.sh )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;I use proc printto to redirect the log&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Why? You can pass in parameters -LOG and -PRINT to define where your output goes. And you can use date and time directives for your log and output so you'll get individually named logs per batch execution.&lt;/P&gt;
&lt;P&gt;Here an example how this could look like (and yes, I prefer to use -sysin as then I can list the .sas file wherever I want).&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;..../Config/Lev1/SASApp/sas.sh&lt;/SPAN&gt;&amp;nbsp;-sysin ".../test/HelloWorld.sas" -log ".../test/#P_#Y#m#d_#H#M#s_#p.log"&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 03:54:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368030#M87704</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-06-18T03:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Unix: passing parameter to a SAS program in command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368347#M87840</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;. I'll try -INITSTMT now and let you know. I prefer working with parameter's tables too. IIn this particulary case, the process will be controled by staff does not have SAS knowledged (TI support), so I'm trying to solve it with minimum changes needed and where the change will be implemented in the same command line.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 14:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368347#M87840</guid>
      <dc:creator>MariaD</dc:creator>
      <dc:date>2017-06-19T14:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: Unix: passing parameter to a SAS program in command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368368#M87849</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've just run the following example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&lt;SPAN&gt;sas &amp;nbsp;/&amp;lt;path&amp;gt;/&amp;lt;program&amp;gt;.sas -initstmt '%let prog=Program1; %let usuario= Natalia UserName;'&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After the execution, the following warning appears in log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;8 %put &amp;amp;prog;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;WARNING: Apparent symbolic reference PROG not resolved.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;amp;prog&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;9 &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;10 %put &amp;amp;usuario;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;WARNING: Apparent symbolic reference USUARIO not resolved.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;amp;usuario&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 15:42:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368368#M87849</guid>
      <dc:creator>MariaD</dc:creator>
      <dc:date>2017-06-19T15:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: Unix: passing parameter to a SAS program in command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368374#M87852</link>
      <description>&lt;P&gt;The -sysparm in you question should work, &amp;nbsp;you can pass multiple parameters in -sysparm option and parse it using scan function in sas file. To redirect your log and lst result to particular file you can use -log and -print options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Modifying your code as below:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;sas /&amp;lt;path&amp;gt;/&amp;lt;program&amp;gt;.sas -sysparm "value1,value2"&lt;/EM&gt; -log anypath/anyname.log -print anypath/anyname.lst&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in your code you can parse -sysparm using scan function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null;&lt;/P&gt;
&lt;P&gt;_value1=scan(sysparm(),1,', ');&lt;BR /&gt;_value2=scan(sysparm(),2,',');&lt;BR /&gt;&amp;nbsp;call symput("value1", "_value1");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;call symput("value2", "_value2");&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 16:14:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368374#M87852</guid>
      <dc:creator>nbonda</dc:creator>
      <dc:date>2017-06-19T16:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Unix: passing parameter to a SAS program in command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368383#M87855</link>
      <description>&lt;P&gt;You need to post your code.&lt;/P&gt;
&lt;P&gt;If you run a program that consists of the just the line.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put _user_;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then your -initstmt method works great.&lt;/P&gt;
&lt;PRE&gt;NOTE: SAS initialization used:
      real time           0.68 seconds
      cpu time            0.02 seconds
      
1          %put _user_;
GLOBAL PROG Program1
GLOBAL USUARIO Natalia UserName
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
      real time           0.78 seconds
      cpu time            0.02 seconds
&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jun 2017 16:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368383#M87855</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-19T16:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Unix: passing parameter to a SAS program in command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368415#M87868</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've just run the following command line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;runsas &amp;nbsp;/&amp;lt;path&amp;gt;/&amp;lt;program&amp;gt;.sas -initstmt '%let prog=/&amp;lt;path&amp;gt;/Program1.sas; %let usuario= Natalia;'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in log, the parameters prog and usuario are not showing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE PRINTTO used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;3&lt;BR /&gt;4 /* Verifica Fecha de Inicio */&lt;BR /&gt;5 %let Fecha_Inicio = %sysfunc(datetime(), datetime19.);&lt;BR /&gt;6&lt;BR /&gt;7 /* Define programa a agendar en Crontab */&lt;BR /&gt;8 %put _user_;&lt;BR /&gt;GLOBAL FECHA_INICIO 19JUN2017:13:42:39&lt;BR /&gt;GLOBAL SYSDBMSG&lt;BR /&gt;GLOBAL SPDS_CLIENT_COMPILED Mar 25 2010&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 18:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368415#M87868</guid>
      <dc:creator>MariaD</dc:creator>
      <dc:date>2017-06-19T18:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Unix: passing parameter to a SAS program in command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368417#M87869</link>
      <description>&lt;P&gt;Looks like your runsas command is NOT passing all of the command line parameters onto the actual call to SAS.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 18:10:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unix-passing-parameter-to-a-SAS-program-in-command-line/m-p/368417#M87869</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-19T18:10:06Z</dc:date>
    </item>
  </channel>
</rss>

