BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

Hello,

 

I have many ksh files that are passing the same parameters but with different values, then start the same SAS program.  If that SAS program is already busy, do we need an option to tell him to wait to end before starting again.

 

For example, imagine that I have two ksh files PSASA and PSASB.  The first one is passing the first parameter = ActMod while the second one is passing the parameter = Quote.

 

Then the same SAS program is started but with ActMod first, then restarted again with the value Quote.

 

The issue I observe, I see no error from Control-M but I don't see any log file for the second call.

 

Any suggestion how to solve that issue?

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 =========> &SYSPARM; 

%let orderdate = %qtrim(%scan(&sysparm.,1,'|',m));
%let ordertime = %qtrim(%scan(&sysparm.,2,'|',m));
%let surveyname = %qtrim(%scan(&sysparm.,3,'|',m));
%let env = %qtrim(%scan(&sysparm.,4,'|',m));

%let ActualDateTime=%sysfunc(putn(%sysfunc(datetime()),datetime21.2));
%let path1=********; /*Confidential*/
%let logpath=/&path1./logs;

proc printto log="&logpath./logfile_&ActualDateTime..log" new;
run;

OPTIONS SASAUTOS=("&path1./saspgm");
%put %sysfunc(pathname(sasautos));

%put &=orderdate &=ordertime &=surveyname &=env;

%include "&path1./saspgm/TxnCnctImptFrmOra.sas";
run;

%TxnCnctImptFrmOra(&orderdate,&ordertime,&name,jsonf);

run;
proc printto;
run;


8 REPLIES 8
Tom
Super User Tom
Super User

Why would it matter that you call the same program multiple times with different inputs?

 

Will that cause the program to try to write different things to the same place?

 

I cannot make heads or tails of the code you posted.  It seems to be a mix of unix commands and SAS code.  The Unix code does not appear to be calling the SAS code anywhere.

 

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.

alepage
Barite | Level 11
dapiupa.ksh file content:


orderdate=$1
ordertime=$2
surveyname=$3
env=$4

#-----------------------------------------------------------
# Cron entries do not execute login scripts.
# Let's run it in the context of our current process
#-----------------------------------------------------------

. /etc/profile

#---------------------------------------------------------------------------------
# Read the parameters and excute the SAS function dapuipa.genjcl.sas
#---------------------------------------------------------------------------------

echo "$orderdate|$ordertime|$name|$env"

sas -sysparm "$orderdate|$ordertime|$name|$env" &path1./sassrc/dapuipa.genjcl.sas

The dapuipa.genjcl.sas start with
%global orderdate surveyname env;

%put =========> &SYSPARM; and so on.
alepage
Barite | Level 11

ERROR: Resource is write-locked by another user. File =/..../dapuipa.genjcl.log. System E\
rror Code = 11.

AlanC
Barite | Level 11

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. 

https://github.com/savian-net
Quentin
Super User

@alepage wrote:

ERROR: Resource is write-locked by another user. File =/..../dapuipa.genjcl.log. System E\
rror Code = 11.


This command to start sas:

sas -sysparm "$orderdate|$ordertime|$name|$env" &path1./sassrc/dapuipa.genjcl.sas

will write the log to &path1./sassrc/dapuipa.genjcl.log

 

So if you run that command twice, and &path1 is the same in both calls, that is likely creating the collision.

 

So as Tom wrote, try adding the -log and -print options to the command SAS so that each call writes its log to a different file.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
AlanC
Barite | Level 11

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): GitHub - savian-net/SasTipsTricks: Tips and tricks learned over 20+ years as a SAS/Microsoft consult...

https://github.com/savian-net
alepage
Barite | Level 11

When the dapiupa.ksh file is trigger, 4 parameters are read then use into the sysparm command below

 

echo "$orderdate|$ordertime|$surveyname|$env"

sas -sysparm "$orderdate|$ordertime|$name|$env" /.../pgm/prod/sassrc/dapuipa.genjcl.sas

 

I dont know which one is lock by another user: dapuipa.genjcl.sas or dapuipa.genjcl.log

 

Does FILELOCKWAIT option might be an options and how to use it ?  

Do we use it with the *.sas file , or the * .log file or both ?

 

 

 

 

 

Quentin
Super User

@alepage wrote:

I dont know which one is lock by another user: dapuipa.genjcl.sas or dapuipa.genjcl.log

 

Does FILELOCKWAIT option might be an options and how to use it ?  

Do we use it with the *.sas file , or the * .log file or both ?

The error message you posted is showing that it is the *.log file that is locked.  

 

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.  So on the command that starts SAS, you need to point the log to a file that is not in use.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1227 views
  • 0 likes
  • 4 in conversation