Desktop productivity for business analysts and programmers

Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

Accepted Solution Solved
Reply
Regular Contributor
Posts: 161
Accepted Solution

Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

[ Edited ]

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.

Kannan Deivasigamani

Accepted Solutions
Solution
‎02-09-2016 02:05 PM
Esteemed Advisor
Posts: 5,198

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

Investigate LOGPARM and ALTLOG system options.

Data never sleeps

View solution in original post


All Replies
Solution
‎02-09-2016 02:05 PM
Esteemed Advisor
Posts: 5,198

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

Investigate LOGPARM and ALTLOG system options.

Data never sleeps
Trusted Advisor
Posts: 1,213

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

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.

Regular Contributor
Posts: 161

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

Thanks @Quentin and @LinusH 

 

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...

 

 

Kannan Deivasigamani
Trusted Advisor
Posts: 1,213

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

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.

Regular Contributor
Posts: 161

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

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'

Kannan Deivasigamani
Trusted Advisor
Posts: 1,213

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

I'm flummoxed. Just for fun, I would try taking the %sysexec out of the macro, and see if that works. Maybe try calling the shell script from EG with systask or X statement. I don't think I'm going to be much help. Very odd.
Regular Contributor
Posts: 161

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

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";

 

 

Kannan Deivasigamani
Super User
Super User
Posts: 6,351

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

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;
Regular Contributor
Posts: 161

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

[ Edited ]

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
      

 

Kannan Deivasigamani
Super User
Super User
Posts: 6,351

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

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.

 

Trusted Advisor
Posts: 1,213

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

@Tom the big surprise to me is that he said when he invoked the script from command prompt, it worked. I assume this means he invoked it with the same command as shown in the SAS macro, redirecting the output.
Super User
Super User
Posts: 6,351

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

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.

Regular Contributor
Posts: 161

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

@LinusH & @Tom 

 

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.

Kannan Deivasigamani
Trusted Advisor
Posts: 1,213

Re: Unable to view log while running SAS program in batch within a Shell on Unix through SAS EG

Wow, that is bizarre (to me at least). Can't think why -altlog would work but not -log. Please post if you learn more from tech support.
@LinusH, curious why you suspected -altlog would work better than -log?
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 15 replies
  • 810 views
  • 3 likes
  • 4 in conversation