BookmarkSubscribeRSS Feed
sergie89
Quartz | Level 8

Hello all,

 

We are using the SAS code below to remove metadata registration of tables which are unloaded from the LASR server.

 

proc metalib;
   omr (LIBRARY="Visual Analytics Public LASR");
   update_rule = (delete noadd noupdate);
   report = ( type=summary );
   /*noexec;*/
run;

However we are using more than 10+ LASR libraries for different departments. So we want to create a SAS program that checks all LASR libraries automatically and remove the metadata registration of unloaded tables from different LASR libraries.

 

Is there an effecient way to perform this action ? We won't copy past the code above each time when we create a new LASR library.

 

Thanks in advance.

2 REPLIES 2
ybolduc
Quartz | Level 8

Hi Sergie,

 

     I would use a data step to find all the appropriate Libraries and add them to a set of macro variables and then loop thru them. Here is a very rough draft of the code (I'm sorry if I made any typo, I don't have a mean to run it at the moment):

%MACRO LASRLibs;

  data _null_;
  
    length uri $60. name $60.;

    count = metadata_getnobj("OMSOBJ:SASLibrary@?Name contains 'LASR'", 1, uri);
    do i = 1 to count;
      rc = metadata_getnobj("OMSOBJ:SASLibrary@?Name contains 'LASR'", i, uri);
      rc = metadata_getattr(uri, 'Name', name);
      call symputx(cats('LIBRARY_', i), name);
      call symputx('LIBRARY_COUNT', i);
    end;
  run;

  %DO I = 1 %TO &LIBRARY_COUNT.;
    proc metalib;
       omr (LIBRARY="&&LIBRARY_&I..");
       update_rule = (delete noadd noupdate);
       report = ( type=summary );
       /*noexec;*/
    run;
  %END;
%MEND;
ybolduc
Quartz | Level 8

Hi Sergie89,

 

     I would do this using a data step to find out all the libraries and them populate a list of macvars. I would then look thru that list of macvars invoking the proc metalib for each of them. Here is a quick draft of what it would look like (please note, I don't have the opportunity to test the code at the moment so it may not run AS IS but should be pretty close to it):

 

%MACRO LASRLibs;

  data _null_;
  
    length uri $60. name $60.;

    count = metadata_getnobj("OMSOBJ:SASLibrary@?Name contains 'LASR'", 1, uri);
    do i = 1 to count;
      rc = metadata_getnobj("OMSOBJ:SASLibrary@?Name contains 'LASR'", i, uri);
      rc = metadata_getattr(uri, 'Name', name);
      call symputx(cats('LIBRARY_', i), name);
      call symputx('LIBRARY_COUNT', i);
    end;
  run;

  %DO I = 1 %TO &LIBRARY_COUNT.;
    proc metalib;
       omr (LIBRARY="&&LIBRARY_&I..");
       update_rule = (delete noadd noupdate);
       report = ( type=summary );
       /*noexec;*/
    run;
  %END;
%MEND;

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1036 views
  • 1 like
  • 2 in conversation