27%macro mf_getuniquelibref(prefix=mc);
30 %
if ( %length(&prefix) gt 7 ) %then %
do;
31 %put %str(ERR)OR: The prefix parameter cannot exceed 7 characters.;
35 %
else %
if (%sysfunc(NVALID(&prefix,v7))=0) %then %
do;
36 %put %str(ERR)OR: Invalid prefix (&prefix);
42 %let maxtries=%eval(10**(8-%length(&prefix))-1);
44 %
do x = 0 %to &maxtries;
45 %
if %sysfunc(libref(&prefix&x)) ne 0 %then %
do;
49 %let x = %eval(&x + 1);
52 %put %str(ERR)OR: No usable libref in range &prefix.0-&maxtries;
53 %put %str(ERR)OR- Try reducing the prefix or deleting some libraries!;
55%mend mf_getuniquelibref;