You can create multiple files in one pass of the data by using the FILEVAR option on the FILE statment. FILEVAR=variable defines a variable whose change in value causes the FILE statement to close the current output file and open a new one the next time the FILE statement executes. The next PUT statement that executes writes to the new file that is specified as the value of the FILEVAR= variable. For example try this program. %let dataset=sashelp.class ; %let n=10 ; %let prefix=~/temp/split ; proc contents data=&dataset noprint out=contents ; run; proc sql noprint ; select varnum , name , quote(trim(coalesce(label,name))) into names , names , :labels separated by " ',' " from contents order by varnum ; quit; data _null_; set &dataset ; _group = 1 + int((_n_-1)/&n) ; _file = cats("&prefix",_group,'.csv'); file csvfile filevar=_file dsd lrecl=100000 ; if mod(_n_,&n)=1 then put &labels ; put (&names) (:) ; run;
... View more