I am trying to figure out how to create a dynamic library reference. I have figured out how to create directories, but now: how to create library references properly?
The code below works, but it required a repeat of the code. The first block does not create a reference, but the second one does. Putting the same into a loop (to execute lines twice) does not work…
I would like to redo this code into a macro, so that the root directory would be assigned when calling the macro.
Thanks in advance!
data _null_;
rootdir='c:/temp';
dir1=put(today(),yymmddn8.);
dir2='Individual';
dir3='Household';
newdir1=dcreate(dir1,rootdir);
newdir2=dcreate(dir2,newdir1);
newdir3=dcreate(dir3,newdir1);
lname=catx('/',rootdir,dir1,dir2);
lname2=catx('/',rootdir,dir1,dir3);
call symput('ln1',lname);
call symput('ln2',lname2);
libname Indiv "&ln1";
libname HH "&ln2";
run;
data _null_;
rootdir='c:/temp';
dir1=put(today(),yymmddn8.);
dir2='Individual';
dir3='Household';
lname=catx('/',rootdir,dir1,dir2);
lname2=catx('/',rootdir,dir1,dir3);
call symput('ln1',lname);
call symput('ln2',lname2);
libname Indiv "&ln1";
libname HH "&ln2";
run;
Seems to do the trick. Not sure if the most efficient way of doing it, but at least it is a way. Thank you Joe for the suggestions that led me to the final answer.