Architecting, installing and maintaining your SAS environment

SAS program to remove metadata registration of all unloaded tables from multiple LASR libraries.

Reply
Occasional Contributor
Posts: 18

SAS program to remove metadata registration of all unloaded tables from multiple LASR libraries.

[ Edited ]

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.

Occasional Contributor
Posts: 13

Re: SAS program to remove metadata registration of all unloaded tables from multiple LASR libraries.

[ Edited ]

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;
Occasional Contributor
Posts: 13

Re: SAS program to remove metadata registration of all unloaded tables from multiple LASR libraries.

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;
Ask a Question
Discussion stats
  • 2 replies
  • 151 views
  • 1 like
  • 2 in conversation