Good morning...!!!
I've the following code that I am trying to test by running a Unix shell invoking SAS batch run as shown below:
(/cml_jobs/cim/dev/users/k85671/scripts/efdwpgm1.sas)
/* SAS code I am trying to test */
proc print data=sashelp.class;
run;
data _null_;
a=today();
drop a;
run;
The script that runs this code is below
(/cml_jobs/cim/dev/users/k85671/scripts/runpgm.sh )
sas -noterminal -log /cml_jobs/cim/dev/users/k85671/scripts/efdwpgm1.log -print /cml_jobs/cim/dev/users/k85671/scripts/efdwpgm1.lst /cml_jobs/cim/dev/users/k85671/scripts/efdwpgm1.sas
The EG code that calls this script above is below
%macro m;
%sysexec %str(
/cml_jobs/cim/dev/users/k85671/scripts/runpgm.sh > /cml_jobs/cim/dev/users/k85671/scripts/runpgm.log
);%mend m;
%m;
After I run the EG code, I see the "efdwpgm.lst" however, I don't see the "efdwpgm1.log" in the directory. Is my syntax incorrect?
I would appreciate any insight into this.
Investigate LOGPARM and ALTLOG system options.
Syntax looks right to me. And you're sure the SAS code is running? (if you delete the .lst file, it will be created when you call the script?). Any chance runpgm.log shows anything interesting?
If you have terminal access to the Unix server, I would try running the sas invocation command there, and see if it creates the log file. Then could back up and run the script and see if it also creates the log file. Then go back to EG. Just to see where along the process it stops working.
When I ran the batch run command on Unix as-is, the program ran and created the log file. No issues...
btw - runpgm.log file from the script was empty when I ran the script before which I did not mention earlier.
I am currently going through the LOG and ALTLOG parms suggested by @LinusHto see if there is anything that can solve this issue...
Since invoking the batch job from command prompt worked, we know it's not a problem with batch sas or permissions, or the syntax of the SAS command.
Did running the shell script from command prompt also work?
If it does, then the problem would seem to be calling the shell script from EG.
It it does not, then the problem is perhaps somehow relating to the shellscript.
I usually put my paths in quotes, you might try that, just for fun, but it shouldn't be required in this case since there are no spaces in your paths.
Yes, running the shell script from command prompt worked. I was able to see the log file updated.
The log file is not updated when calling the shell script from EG. However, the .lst file is updated with refreshed listing.
I added the quotes as you recommended (pasted below) and ran from EG - the log is still not updating but the list updates.
sas -noterminal -log '/cml_jobs/cim/dev/users/k85671/scripts/efdwpgm1.log' -print '/cml_jobs/cim/dev/users/k85671/scripts/efdwpgm1.lst' '/cml_jobs/cim/dev/users/k85671/scripts/efdwpgm1.sas'
Thanks for your trial suggestions @Quentin. I tried to run the script using systask (pasted below), the log is still not updated but the list is updated...
systask command "/cml_jobs/cim/dev/users/k85671/scripts/runpgm.sh";
First step in debugging this type of issue is to not use %SYSEXEC, SYSTEM, X, or other commands to run the OS comand.
Instead run it via a PIPE in a data step. That way you can see the error messages that the command is generating.
data _null_;
infile %sysfunc(quote(
/cml_jobs/cim/dev/users/k85671/scripts/runpgm.sh > cml_jobs/cim/dev/users/k85671/scripts/runpgm.log
)) pipe ;
input;
put _infile_;
run;
Thanks @Tom. I just tried the pipes and didn't see any errors but the issue still persists. I still don't see the saslog.
24 options nocenter obs=max mlogic mprint symbolgen msglevel=i errors=1;
25
26 data _null_;
27 infile %sysfunc(quote(
28 /cml_jobs/cim/dev/users/k85671/scripts/runpgm.sh > /cml_jobs/cim/dev/users/k85671/scripts/runpgm.log
29 )) pipe ;
30 input;
31 put _infile_;
32 run;
NOTE: The infile "/cml_jobs/cim/dev/users/k85671/scripts/runpgm.sh > /cml_jobs/cim/dev/users/k85671/scripts/runpgm.log" is:
Pipe command="/cml_jobs/cim/dev/users/k85671/scripts/runpgm.sh > /cml_jobs/cim/dev/users/k85671/scripts/runpgm.log"
NOTE: 0 records were read from the infile "/cml_jobs/cim/dev/users/k85671/scripts/runpgm.sh >
/cml_jobs/cim/dev/users/k85671/scripts/runpgm.log".
NOTE: DATA statement used (Total process time):
real time 1.63 seconds
cpu time 0.01 seconds
Either look at the file (
/cml_jobs/cim/dev/users/k85671/scripts/runpgm.log
) that you redirected the output to. Or remove the redirection from the command you are running.
Also try running the commands in the script directly instead of calling the script. Perhaps the individual commands in the script file are not duing what you expected.
Please try running the actual call to launch SAS instead of the call to the script. Or at least post the script and any output that it redirected to that log file. Are you sure that you are not directing both the SASLOG and the output of the shell script to the same log file? That would cause trouble. Try using the -ALTLOG option to direct another copy of the the SAS log to another file.
you were correct. It took a while for me to research and get the syntax and test this ALTLOG option. It did the job.
All I had to do was change -log to -altlog and the rest of the command was the same.... I still wonder where the original log was being written to. I've opened a tracking# with SAS... will see what their advice is...
You guys are awesome... !!! You are real code doctors....kudos.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.