I haven't found an elegant solution, but I'm using this code in Enterprise Guide:
*-- start code --;
data _NULL_;
length WORD $8;
do j = 1 to 8;
WORD = byte(int(65 + ranuni(0)*26)) || WORD;
end;
call symput("mylibrary", WORD);
run;
libname &mylibrary 'physical_path_to_library';
*-- end code --;
This assign every time a different random LIBREF to you library.
It works.
Regards
Paolo
without the data step code, you can assign a "random" libref like
libname A%scan( %sysfunc( ranuni(0), 9.7 ),2,.) 'physical path to library' ;
it creates a libref that is unlikely to repeat having a random 7 digit number following that A.
I just tested it and it even works within a %sysfunc( repeat( ,4 )) where it happily assigned 5 unique libnames (all with the same path)
%sysfunc( repeat( %nrstr(
libname A %%scan( %%sysfunc( ranuni(0), 9.7 ), 2, . ) 'my path' ;
), 4 ) ) ;
The reason the macros libname won't release is its use in option sasmstore=macros ;
I'm not sure you can release the sasmstore assignment. (nor sure I would want to release it)
Use Scott's approach - not performing the assignment of the macros libname after the first run. Place "one-time-only" code in the autoexec.
Peter
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.