Architecting, installing and maintaining your SAS environment

Accepted Solution

running SAS in parallel using SLURM job arrays

Reply
Super User
Super User
Posts: 6,842

Re: running SAS in parallel using SLURM job arrays

[ Edited ]

Your dump of the hex codes looks fine, '33'x is the digit 3 and '20'x is a space.  SAS uses fixed length fields so all variables are padded with spaces.

 

Perhaps your only issue is that you are overwriting your SAS logs?

Use the -log and -print command line options to re-direct the SAS log and listing outputs to different files.

For example you might add run1, run2, etc to the filenames.

 

#!/bin/ksh
n=1
fn=myprogram
sas -sysparm $n -sysin ${fn}.sas -log ${fn}_run${n}.log -print ${fn}_run${n}.lst

 You might also want to look into the -stdio command line option which will take the program code from standard input and direct the log and listing to standard output and standard error.

Highlighted
Occasional Contributor
Posts: 14

Re: running SAS in parallel using SLURM job arrays

Thanks again for these very helpful thoughts!  The failure of:

 

%let TskID=&sysparm;
%put &TskID;

 

persists, despite my avoidance of SAS log overwriting (as of just now).  What a mystery!  I will return to this issue in a few days, but appreciate your efforts.  Maybe alternatives will arise eventually.

Occasional Contributor
Posts: 14

Re: running SAS in parallel using SLURM job arrays

The following paragraph:

 

LIBNAME myplace "/home/username/";
DATA myplace.x&TskID;
  LENGTH TskID $200 ;
  TskID=symget('sysparm');
  RETAIN TskID;
RUN;

 

allows me to save TskID to an appropriately-named sas7bdat file (x1, x2 or x3); the parameter value is henceforth available to me later.  This solution seems rather cumbersome.  I'm curious whether anyone can offer a more elegant way of doing this.  As discussed earlier, for some reason

 

%let TskID=&sysparm;
%put &TskID;

 

does not work for me.  Thanks very much for your guidance!

Occasional Contributor
Posts: 14

Re: running SAS in parallel using SLURM job arrays

Interesting.  If, in my shell script, I replace

 

#SBATCH --array=1-3

 

by

 

#SBATCH --array=1993-1995

 

(actual years rather than small indices), then the SAS commands

 

%let TskID=&sysparm;
%put &TskID;

 

suddenly work!  This is an unexpected but gratifying resolution. 

 

Might such behavior be a SAS bug?  Namely, when the environment variable $SLURM_ARRAY_TASK_ID is small, it fails to be properly passed from shell script to SAS program. 

 

☑ This topic is solved.

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

Discussion stats
  • 18 replies
  • 370 views
  • 0 likes
  • 4 in conversation