BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
L2Fly
Pyrite | Level 9

Hello everyone,  in advance I apologize if this post in a wrong location.  I have been working to develop a process (using SAS Macro and code) to unload and load data into LASR.  I have had success doing it via this code

%macro loadLasr(LibName, LibLASR_Name, LibraryPath, LASR_FolderPath, TableName, LASR_TName, );
    /*Load data into LASR*/
	DATA &LibLASR_Name..&LASR_TName;
    	set &LibName..&TableName;
	run;
    /*Register data into Metadata*/
	PROC METALIB;
		omr(library = &LibraryPath);
		folder= &LASR_FolderPath;
		select=(&LASR_TName);
	run;  
%mend loadLasr;

It works but I also want to add the Description to it.  When I load a table into LASR via Visual Analytics Administrator tool then I can add the description but when I unload and then reload the tables through code I will loose the description.  I want to know if I can add the description as a parameter to above code to be added to the LASR. 

 

 

thanks for your info and help

1 ACCEPTED SOLUTION

Accepted Solutions
alexal
SAS Employee

@L2Fly,

 

-3 means "No objects match the URI.". Make sure that the table has been registered in the metadata. I'm using the following macro to do that:

/* Register Table Macro */
%macro registertable( REPOSITORY=Foundation, REPOSID=, LIBRARY=, TABLE=, FOLDER=, TABLEID=, PREFIX= );

/* Mask special characters */

   %let REPOSITORY=%superq(REPOSITORY);
   %let LIBRARY   =%superq(LIBRARY);
   %let FOLDER    =%superq(FOLDER);
   %let TABLE     =%superq(TABLE);

   %let REPOSARG=%str(REPNAME="&REPOSITORY.");
   %if ("&REPOSID." ne "") %THEN %LET REPOSARG=%str(REPID="&REPOSID.");

   %if ("&TABLEID." ne "") %THEN %LET SELECTOBJ=%str(&TABLEID.);
   %else                         %LET SELECTOBJ=&TABLE.;

   %if ("&FOLDER." ne "") %THEN
      %PUT INFO: Registering &FOLDER./&SELECTOBJ. to &LIBRARY. library.;
   %else
      %PUT INFO: Registering &SELECTOBJ. to &LIBRARY. library.;

   proc metalib;
      omr (
         library="&LIBRARY." 
         %str(&REPOSARG.) 
          ); 
      %if ("&TABLEID." eq "") %THEN %DO;
         %if ("&FOLDER." ne "") %THEN %DO;
            folder="&FOLDER.";
         %end;
      %end;
      %if ("&PREFIX." ne "") %THEN %DO;
         prefix="&PREFIX.";
      %end;
      select ("&SELECTOBJ."); 
   run; 
   quit;

%mend;

Here is usage example:

/* Synchronize table registration */
%registerTable(
     LIBRARY=%nrstr(/Shared Data/SAS Visual Analytics/Public/Visual Analytics Public LASR)
   , REPOSITORY=%nrstr(Foundation)
   , TABLE=%nrstr(CARS)
   , FOLDER=%nrstr(/Shared Data/SAS Visual Analytics/Public/LASR)
   );

View solution in original post

6 REPLIES 6
alexal
SAS Employee

@L2Fly,

 

Here is the code:

 

data _null_;
  rc=metadata_setattr("omsobj:PhysicalTable?@Name='<REPLACE_WITH_TABLE_NAME>'","Desc","<YOUR_COMMENT>");
  put rc=;
run;
L2Fly
Pyrite | Level 9

Thank you @alexal,

 

I am very new into SAS and SAS programming so something like this would work?   Based on your code I found this http://support.sas.com/documentation/cdl/en/lrmeta/60739/HTML/default/viewer.htm#setattr.htm but not sure "PhysicalTable" refers to my parameter TableName ...

 

%macro loadLasr(LibName, LibLASR_Name, LibraryPath, LASR_FolderPath, TableName, LASR_TName, );
    /*Load data into LASR*/
	DATA &LibLASR_Name..&LASR_TName;
    	set &LibName..&TableName;
	run;
	data _null_;
  		rc=metadata_setattr("omsobj:PhysicalTable?@Name="&LASR_TName,"Desc","testing");
  		put rc=;
	run;

    /*Register data into Metadata*/
	PROC METALIB;
		omr(library = &LibraryPath);
		folder= &LASR_FolderPath;
		select=(&LASR_TName);
	run;  
%mend loadLasr;
alexal
SAS Employee

@L2Fly,

 

It will be &LASR_TName. Also, make sure that you have executed that code after proc metalib. Otherwise, you won't have anything to change.

L2Fly
Pyrite | Level 9

I am sure I am not doing this correctly, log indicates

NOTE: 0 tables listed in the SELECT or EXCLUDE statement were not found in either the metadata or the data source.

NOTE: 0 other tables were not processed due to error or UPDATE_RULE.

NOTE: PROCEDURE METALIB used (Total process time):

real time 1.70 seconds

cpu time 0.04 seconds

 

 

rc=-3

NOTE: DATA statement used (Total process time):

real time 0.00 seconds

cpu time 0.01 seconds

 

%macro loadLasr(LibName, LibLASR_Name, LibraryPath, LASR_FolderPath, TableName, LASR_TName );
    /*Load data into LASR*/
	DATA &LibLASR_Name..&LASR_TName;
    	set &LibName..&TableName;
	run;

    /*Register data into Metadata*/
	PROC METALIB;
		omr(library = &LibraryPath);
		folder= &LASR_FolderPath;
		select=(&LASR_TName);
	run;  

	data _null_;
  		rc=metadata_setattr("omsobj:&LASR_TName?@Name=&LASR_TName","Desc","testing");
  		put rc=;
	run;
%mend loadLasr;

 

alexal
SAS Employee

@L2Fly,

 

-3 means "No objects match the URI.". Make sure that the table has been registered in the metadata. I'm using the following macro to do that:

/* Register Table Macro */
%macro registertable( REPOSITORY=Foundation, REPOSID=, LIBRARY=, TABLE=, FOLDER=, TABLEID=, PREFIX= );

/* Mask special characters */

   %let REPOSITORY=%superq(REPOSITORY);
   %let LIBRARY   =%superq(LIBRARY);
   %let FOLDER    =%superq(FOLDER);
   %let TABLE     =%superq(TABLE);

   %let REPOSARG=%str(REPNAME="&REPOSITORY.");
   %if ("&REPOSID." ne "") %THEN %LET REPOSARG=%str(REPID="&REPOSID.");

   %if ("&TABLEID." ne "") %THEN %LET SELECTOBJ=%str(&TABLEID.);
   %else                         %LET SELECTOBJ=&TABLE.;

   %if ("&FOLDER." ne "") %THEN
      %PUT INFO: Registering &FOLDER./&SELECTOBJ. to &LIBRARY. library.;
   %else
      %PUT INFO: Registering &SELECTOBJ. to &LIBRARY. library.;

   proc metalib;
      omr (
         library="&LIBRARY." 
         %str(&REPOSARG.) 
          ); 
      %if ("&TABLEID." eq "") %THEN %DO;
         %if ("&FOLDER." ne "") %THEN %DO;
            folder="&FOLDER.";
         %end;
      %end;
      %if ("&PREFIX." ne "") %THEN %DO;
         prefix="&PREFIX.";
      %end;
      select ("&SELECTOBJ."); 
   run; 
   quit;

%mend;

Here is usage example:

/* Synchronize table registration */
%registerTable(
     LIBRARY=%nrstr(/Shared Data/SAS Visual Analytics/Public/Visual Analytics Public LASR)
   , REPOSITORY=%nrstr(Foundation)
   , TABLE=%nrstr(CARS)
   , FOLDER=%nrstr(/Shared Data/SAS Visual Analytics/Public/LASR)
   );
L2Fly
Pyrite | Level 9

Thank you @alexal for your help.  I will take a look and try to do the same in my environment.  Will keep you posted.

 

Best

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1139 views
  • 1 like
  • 2 in conversation