In reply to Leonid Batkhan.

Hi Leonid,

My solution won't generalize to as many situations as yours, but is a good fit for my colleagues who are most likely to use it. I typically set things up so they can edit key macro variables in a clearly delineated section at the top of a SAS file, and then submit the entire file.

It will take a variable format external file on a z/OS system, regardless of how large, and split it into files of a user-specified number of lines, up to a maximum of 999999 lines per file, allocating the files on the fly. From looking at this code, it may not be obvious how your previous response helped me with this. You know how when you're working your way iteratively through attempts to solve a problem, they tend to become progressively more complex? Your post reminded me that sometimes, it's more effective to refocus on simplifying your approach.

Here's where that got me:

rsubmit;
************* EDIT THESE VARIABLES *************;
* input source filename;
%let myinfile='source.file.on.main.frame';

* base name of the files to allocate, with no numeric suffix;
%let filestem=username.output.slice;

* max number of records to write per file;
%let maxrecs=600000;

************** END OF VARIABLES TO EDIT **************;

data _null_;
infile &myinfile;
if _n_ eq 1 then do;
stem = symget('filestem');
* specifying 6. limits maxrecs to < 1 million records;
maxrecs = input(symget('maxrecs'),6.);
filenum = 0;
retain stem maxrecs filenum;
end;

if (mod(_n_,maxrecs) eq 1) then do;
outfile = cats("'",stem,filenum,"'");
rc = filename('slice', outfile, 'disk','disp=(new,catlg) label=(,,,,expdt=99365) space=(15643,(10000,2000),rlse) recfm=vb lrecl=15643 noprompt');
filenum = filenum + 1;
end;

input;
file dummy filevar=outfile;
put _infile_;
run;

filename _all_ clear;
endrsubmit;

Thanks again,

Rebekah