BookmarkSubscribeRSS Feed
MB_Analyst
Obsidian | Level 7

I have syntax that, when run in batch mode, is significantly slower than in an interactive session. I checked the output of proc options;run; and I'm not seeing any major differences. Steps that often bog down in batch mode are anything I/O, or proc sort. For example, the following code snippets takes a less than 3 minutes each during an interactive session, and 10+ minutes each in batch. Although the real time increases to around 10 minutes, the CPU time remains around ~5 seconds. 

/* Example sql pull from server location */
proc sql; create table want as select a.*, b.* from have1 a left join have2 b on a.id = b.id order by a.id, a.date; quit;
/* example data step with work library */
data want2;
    set want(where=(id ne .));
    by id date;
    if first.id then output;
run;

My guess is the difference could be due to a number of things, but wondering if anyone had thoughts on options to check? The code runs daily, and I plan to add FULLSTIMER to get a better sense of bottlenecks. Any ideas why batch would be double+ the time to run?

 

Edit to add in a difference in CONFIG locations:

Batch CONFIG:

CONFIG=( "C:\Program Files\SASHome\SASFoundation\9.4\sasv9.cfg" "C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg" )

Interactive CONFIG:

CONFIG=C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg
8 REPLIES 8
MB_Analyst
Obsidian | Level 7

Should I check something for these beyond the options output?

Both batch and interactive mode options have:
UTILLOC=WORK

And the WORK is set to my local temp files (C:\Users\username~1\AppData\Local\Temp\SAS Temporary Files\_TDxxxx_)

 

MB_Analyst
Obsidian | Level 7

I will look into this. It could be promising because if I run the .bat manually (i.e. double clicking), it runs much faster than when the schedule tasks prompts the .bat. 

I will change the priority based on this webpage's info, as I confirmed SAS is set at a lower priority when run from a batch file.  

Ksharp
Super User
Do you have LOG of batch mode ? Like *.log

"D:\SASHome\SASFoundation\9.4\sas.exe" -nosplash -sysin "c:\temp\temp.sas" -log "c:\temp\temp#Y#m#d-#H-#M-#s.log" -logparm "rollover=auto" -set dsn "sashelp.air" -set age "'01jan1955'd"
MB_Analyst
Obsidian | Level 7

I do have the log being output. A scheduled task runs a "master file" that outputs in one location, and runs %include statements to run other code. The %include statements use proc printto to output individual .log files for each syntax file. 

The bat file consists of the following:

"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -SYSIN "C:\path\to\master\masterCode.sas" -log "C:\path\to\logs\%DATESTAMP%_masterLog.log" -noprint
Ksharp
Super User
Then check your LOG file and could find out which part of code is the most wasting time .
Tom
Super User Tom
Super User

Compare the CPU times between the two runs instead of just the REAL times.  It could just be that the job is running with lower priority or when the machine is busier.

 

Are you running multiple SAS sessions at the same time?  If they are all using the same disk for WORK then there will be a lot of disk contention in addition to needing to share the CPU.

 

Note if you are going to be running multiple SAS sessions are the same time then make sure to use the RSASUSER option when you start SAS.   This will open the SASUSER libref in readonly mode.  Then when you try to open a new interactive SAS session while another SAS session is running you still get access to your personalized settings, like window locations and key mappings.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 8 replies
  • 1585 views
  • 2 likes
  • 4 in conversation