Search code examples
sasmetadata

Register SAS data in metadata using metalib


I created a new view in SAS using PROC SQL. Now I'd like to register the view in the metadata in order to enable other users to use the view on a metadata-driven basis.

Using PROC METALIB I'm supposed to be able to do this. I'm required to provide both a library reference (OMR statement) and a dataset reference (SELECT statement). However, the library was already defined when I created the view.

Am I supposed to provide the libref twice or is there a way to register the view with the pre-existing libref that has been provided in the PROC SQL?

If I'm doing this wrong - what would be the correct way to do this using a SAS program?

Example:

PROC SQL;
   CREATE VIEW mylib.myview AS
      SELECT * FROM mytable;
QUIT;

PROC METALIB;
   OMR (library="mylib");
   SELECT ("mylib.myview");
   REPORT;
RUN;


Solution

  • You need to pass the full name of the name attribute in metadata. Not just the libref.

    If you want to just pass the libref you can use.

    proc metalib;
      omr (liburi="SASLibrary?@libref='mylib'");
      update_rule=(delete);
         select ("mytable");
    
    run;