BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kannand
Lapis Lazuli | Level 10

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
1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

Investigate LOGPARM and ALTLOG system options.

Data never sleeps

View solution in original post

15 REPLIES 15
LinusH
Tourmaline | Level 20

Investigate LOGPARM and ALTLOG system options.

Data never sleeps
Quentin
Super User

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.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
kannand
Lapis Lazuli | Level 10

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
Quentin
Super User

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.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
kannand
Lapis Lazuli | Level 10

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
Quentin
Super User
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.
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
kannand
Lapis Lazuli | Level 10

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
Tom
Super User Tom
Super User

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;
kannand
Lapis Lazuli | Level 10

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
Tom
Super User Tom
Super User

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.

 

Quentin
Super User
@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.
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Tom
Super User Tom
Super User

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.

kannand
Lapis Lazuli | Level 10

@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
Quentin
Super User
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?
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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