<?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: Using a ksh file to pass parameters and to trigger a SAS program in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877269#M43005</link>
    <description>dapiupa.ksh file content:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;orderdate=$1&lt;BR /&gt;ordertime=$2&lt;BR /&gt;surveyname=$3&lt;BR /&gt;env=$4&lt;BR /&gt;&lt;BR /&gt;#-----------------------------------------------------------&lt;BR /&gt;# Cron entries do not execute login scripts.&lt;BR /&gt;# Let's run it in the context of our current process&lt;BR /&gt;#-----------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;. /etc/profile&lt;BR /&gt;&lt;BR /&gt;#---------------------------------------------------------------------------------&lt;BR /&gt;# Read the parameters and excute the SAS function dapuipa.genjcl.sas&lt;BR /&gt;#---------------------------------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;echo "$orderdate|$ordertime|$name|$env"&lt;BR /&gt;&lt;BR /&gt;sas  -sysparm  "$orderdate|$ordertime|$name|$env" &amp;amp;path1./sassrc/dapuipa.genjcl.sas&lt;BR /&gt;&lt;BR /&gt;The dapuipa.genjcl.sas start with&lt;BR /&gt;%global orderdate surveyname env;&lt;BR /&gt;&lt;BR /&gt;%put =========&amp;gt; &amp;amp;SYSPARM;  and so on.&lt;BR /&gt;</description>
    <pubDate>Wed, 24 May 2023 13:34:08 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2023-05-24T13:34:08Z</dc:date>
    <item>
      <title>Using a ksh file to pass parameters and to trigger a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877264#M43003</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have many ksh files that are passing the same parameters but with different values, then start the same SAS program.&amp;nbsp; If that SAS program is already busy, do we need an option to tell him to wait to end before starting again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, imagine that I have two ksh files PSASA and PSASB.&amp;nbsp; The first one is passing the first parameter = ActMod while the second one is passing the parameter = Quote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the same SAS program is started but with ActMod first, then restarted again with the value Quote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue I observe, I see no error from Control-M but I don't see any log file for the second call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestion how to solve that issue?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;orderdate=$1
ordertime=$2
surveyname=$3
env=$4


echo $HOME
echo $HOME/bin

$HOME/bin/dapiupa.ksh "$orderdate" "$ordertime" "$name" "$env"

if test $? -lt 2
then
   exit 0
fi

exit $?

#--------------------
# Exit procedure
#--------------------

So in the first call name=ActMod while in the second call name= Quote.

%global orderdate surveyname env;

%put =========&amp;gt; &amp;amp;SYSPARM; 

%let orderdate = %qtrim(%scan(&amp;amp;sysparm.,1,'|',m));
%let ordertime = %qtrim(%scan(&amp;amp;sysparm.,2,'|',m));
%let surveyname = %qtrim(%scan(&amp;amp;sysparm.,3,'|',m));
%let env = %qtrim(%scan(&amp;amp;sysparm.,4,'|',m));

%let ActualDateTime=%sysfunc(putn(%sysfunc(datetime()),datetime21.2));
%let path1=********; /*Confidential*/
%let logpath=/&amp;amp;path1./logs;

proc printto log="&amp;amp;logpath./logfile_&amp;amp;ActualDateTime..log" new;
run;

OPTIONS SASAUTOS=("&amp;amp;path1./saspgm");
%put %sysfunc(pathname(sasautos));

%put &amp;amp;=orderdate &amp;amp;=ordertime &amp;amp;=surveyname &amp;amp;=env;

%include "&amp;amp;path1./saspgm/TxnCnctImptFrmOra.sas";
run;

%TxnCnctImptFrmOra(&amp;amp;orderdate,&amp;amp;ordertime,&amp;amp;name,jsonf);

run;
proc printto;
run;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 May 2023 12:58:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877264#M43003</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-05-24T12:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using a ksh file to pass parameters and to trigger a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877266#M43004</link>
      <description>&lt;P&gt;Why would it matter that you call the same program multiple times with different inputs?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will that cause the program to try to write different things to the same place?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cannot make heads or tails of the code you posted.&amp;nbsp; It seems to be a mix of unix commands and SAS code.&amp;nbsp; The Unix code does not appear to be calling the SAS code anywhere.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to keep the log and listing files generated straight make sure to add the -log and -print options to the command used to start SAS so that each call writes its log to a different file.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 13:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877266#M43004</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-24T13:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using a ksh file to pass parameters and to trigger a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877269#M43005</link>
      <description>dapiupa.ksh file content:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;orderdate=$1&lt;BR /&gt;ordertime=$2&lt;BR /&gt;surveyname=$3&lt;BR /&gt;env=$4&lt;BR /&gt;&lt;BR /&gt;#-----------------------------------------------------------&lt;BR /&gt;# Cron entries do not execute login scripts.&lt;BR /&gt;# Let's run it in the context of our current process&lt;BR /&gt;#-----------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;. /etc/profile&lt;BR /&gt;&lt;BR /&gt;#---------------------------------------------------------------------------------&lt;BR /&gt;# Read the parameters and excute the SAS function dapuipa.genjcl.sas&lt;BR /&gt;#---------------------------------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;echo "$orderdate|$ordertime|$name|$env"&lt;BR /&gt;&lt;BR /&gt;sas  -sysparm  "$orderdate|$ordertime|$name|$env" &amp;amp;path1./sassrc/dapuipa.genjcl.sas&lt;BR /&gt;&lt;BR /&gt;The dapuipa.genjcl.sas start with&lt;BR /&gt;%global orderdate surveyname env;&lt;BR /&gt;&lt;BR /&gt;%put =========&amp;gt; &amp;amp;SYSPARM;  and so on.&lt;BR /&gt;</description>
      <pubDate>Wed, 24 May 2023 13:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877269#M43005</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-05-24T13:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using a ksh file to pass parameters and to trigger a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877271#M43006</link>
      <description>&lt;P&gt;ERROR: Resource is write-locked by another user. File =/..../dapuipa.genjcl.log. System E\&lt;BR /&gt;rror Code = 11.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 13:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877271#M43006</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-05-24T13:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using a ksh file to pass parameters and to trigger a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877273#M43007</link>
      <description>&lt;P&gt;Each thread should be on its own. I do not use Unix but have done this type of work numerous times using SAS and/or C#. Make sure you have a unique identifier in each execution so you don't use same resources (ex. log file). You can also do it in SAS. See this entry (Submitting Jobs in Parallel):&amp;nbsp;&lt;A href="https://github.com/savian-net/SasTipsTricks#submitting-jobs-in-parallel" target="_blank" rel="noopener"&gt;GitHub - savian-net/SasTipsTricks: Tips and tricks learned over 20+ years as a SAS/Microsoft consultant&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 13:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877273#M43007</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2023-05-24T13:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using a ksh file to pass parameters and to trigger a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877276#M43008</link>
      <description>&lt;P&gt;Exactly. You need an identifier to be in the log file that is a unique value. A random number probably wouldn't work because it is a duplicate (normally) for fast submissions (grain of salt here since it is a big subject). If you are submitting in a sequence, just append a counter.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 13:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877276#M43008</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2023-05-24T13:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using a ksh file to pass parameters and to trigger a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877279#M43009</link>
      <description>&lt;P&gt;When the dapiupa.ksh file is trigger, 4 parameters are read then use into the sysparm command below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;echo "$orderdate|$ordertime|$surveyname|$env"&lt;/P&gt;
&lt;P&gt;sas -sysparm "$orderdate|$ordertime|$name|$env" /.../pgm/prod/sassrc/dapuipa.genjcl.sas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I dont know which one is lock by another user: dapuipa.genjcl.sas or&amp;nbsp;dapuipa.genjcl.log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does&amp;nbsp;&lt;SPAN&gt;FILELOCKWAIT option might be an options and how to use it ?&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Do we use it with the *.sas file , or the * .log file or both ?&lt;/SPAN&gt;&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>Wed, 24 May 2023 14:15:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877279#M43009</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-05-24T14:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using a ksh file to pass parameters and to trigger a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877280#M43010</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;ERROR: Resource is write-locked by another user. File =/..../dapuipa.genjcl.log. System E\&lt;BR /&gt;rror Code = 11.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This command to start sas:&lt;/P&gt;
&lt;PRE&gt;sas -sysparm "$orderdate|$ordertime|$name|$env" &amp;amp;path1./sassrc/dapuipa.genjcl.sas&lt;/PRE&gt;
&lt;P&gt;will write the log to&amp;nbsp;&amp;amp;path1./sassrc/dapuipa.genjcl.log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you run that command twice, and &amp;amp;path1 is the same in both calls, that is likely creating the collision.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So as Tom wrote, try &lt;SPAN&gt;adding the -log and -print options to the command SAS so that each call writes its log to a different file.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 14:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877280#M43010</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-05-24T14:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using a ksh file to pass parameters and to trigger a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877282#M43011</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I dont know which one is lock by another user: dapuipa.genjcl.sas or&amp;nbsp;dapuipa.genjcl.log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does&amp;nbsp;&lt;SPAN&gt;FILELOCKWAIT option might be an options and how to use it ?&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Do we use it with the *.sas file , or the * .log file or both ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The error message you posted is showing that it is the *.log file that is locked.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think FILELOCKWAIT can help you, because this collision is not happening within SAS, it's happening when you try to start SAS.&amp;nbsp; So on the command that starts SAS, you need to point the log to a file that is not in use.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 14:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Using-a-ksh-file-to-pass-parameters-and-to-trigger-a-SAS-program/m-p/877282#M43011</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-05-24T14:30:05Z</dc:date>
    </item>
  </channel>
</rss>

