CORE
mm_assignlib.sas
Go to the documentation of this file.
1 
23 %macro mm_assignlib(
24  libref
25  ,mDebug=0
26  ,mAbort=0
27  );
28 
29 %local mD;
30 %if &mDebug=1 %then %let mD=;
31 %else %let mD=%str(*);
32 %&mD.put Executing mm_assignlib.sas;
33 %&mD.put _local_;
34 
35 %if &mAbort=1 %then %let mAbort=;
36 %else %let mAbort=%str(*);
37 
38 %if %sysfunc(libref(&libref)) %then %do;
39  data _null_;
40  length lib_uri LibName $200;
41  call missing(of _all_);
42  nobj=metadata_getnobj("omsobj:SASLibrary?@Libref='&libref'",1,lib_uri);
43  if nobj=1 then do;
44  rc=metadata_getattr(lib_uri,"Name",LibName);
45  call symputx('LIB',libname,'L');
46  end;
47  else if nobj>1 then do;
48  &mD.putlog "ERROR: More than one library with libref=&libref";
49  &mAbort.call execute('%mf_abort(msg=
50  ERROR: More than one library with libref='!!"&libref
51  ,mac=mm_assignlib.sas)");
52  end;
53  else do;
54  &mD.putlog "ERROR: Library &libref not found in metadata";
55  &mAbort.call execute('%mf_abort(msg=ERROR: Library '!!"&libref"
56  !!' not found in metadata,mac=mm_assignlib.sas)');
57  end;
58  run;
59 
60  libname &libref meta library="&lib";
61  %if %sysfunc(libref(&libref)) %then %do;
62  %&mD.put ERROR: mm_assignlib macro could not assign &libref;
63  %&mAbort.mf_abort(
64  msg=ERROR: mm_assignlib macro could not assign &libref
65  ,mac=mm_assignlib.sas);
66  %end;
67 %end;
68 %else %do;
69  %&mD.put NOTE: Library &libref is already assigned;
70 %end;
71 %mend;