%macro libnamer(filetype,subdir,libref=,opts=%str(access=readonly),server=oseda); %*--variation on libname macro by John Blodgett, U of Missouri St. Louis. Used in local windows environment to define a libname referencing a remote server (mcdc, by default).--; %*--macro generates a libname stmt for a "filetype" on the remote server data archive. If the filetype (subdirectory) does not exist then the libname statement is issued and a NOTE: message is written to the SAS log telling you that the library does not exist. Samples: Invocation Generates this code (=/mscdc/data) =========== ====================================== %libnamer(stf803) libname REMOTE stf803 "/stf803" server=oseda access=readonly ; %if &server=mcdc %then %let datadir=%str(/pub/data); %else %if &server=oseda %then %let datadir=%str(/mscdc/data); %else %do; %put ****Server &server not recognized. libnamer will generate no code ****; %goto endmac; %end; %if %quote(&libref) eq %str() %then %do; %if %quote(&subdir) eq %str() %then %let libref=&filetype; %else %do; %let lconcat=%eval(%length(&filetype) + %length(&subdir); %if %eval(&lconcat) le 8 %then %let libref=&filetype.&subdir; %else %let libref=&subdir; %end; %end; %if &subdir ne %then %let subdir=&filetype%quote(/)&subdir; %else %let subdir=&filetype; libname &libref REMOTE "&datadir/&subdir" server=&server &opts; %endmac: %mend libnamer;