%macro dirinit(app,sasout=1); %*--utility macro to make a websas application directory. By default it will generate a "libname sasout ... " statement to reference the new directory as sasout. Uses an "x cd " statement to make the new dir the current dir. Global parm &jobid is (usually) assigned here. It is of the form ddMMMyy_nnnnn - the date and a sequential job # within that date. Also global &jobno (the nnnnn value). Adapted from routine orginally written for the dexter websas app. Macrofied 4-3-07, jgb --; %global jobid jobno; x cd /SAS_temp; %if %superq(jobid) ne %str() %then %do; %let tmpdir=/SAS_temp/&jobid..&app; %if sysfunc(fileexist(&tmpdir)) %then %goto aftmkdir; %else %put ***No temp directory found for jobid &jobid . Ignoring jobid parm***; %end; *options symbolgen; filename xdirs pipe "ls -ld &sysdate.*.&app"; %let jobno=00001; *<---default value in case the pipe yields no data--; data ; ** _null_; infile xdirs end=_eof; input ; length dirno $5; dirno=scan(_infile_,-2,'_ .'); if dirno='not' then stop; *<--getting does not exist msg-; if _eof then do; length jobno 8; jobno=input(dirno,5.) + 1; call symput('jobno',trim(left(put(jobno,z5.)))); end; run; %put &jobno; %let jobid=&sysdate._&jobno; x mkdir &jobid..&app; %aftmkdir: x cd /SAS_temp/&jobid..&app; %if &sasout %then %do; libname sasout "/SAS_temp/&jobid..&app"; %end; x pwd; %mend dirinit;