Exploring, predicting and reporting with SAS Visual Analytics and SAS Visual Statistics

How to add Description to a LASR table when loading it via code and not through Visual Analytics ADM

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 80
Accepted Solution

How to add Description to a LASR table when loading it via code and not through Visual Analytics ADM

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


Accepted Solutions
Solution
‎05-02-2018 10:48 AM
SAS Employee
Posts: 547

Re: How to add Description to a LASR table when loading it via code and not through Visual Analytics

@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


All Replies
SAS Employee
Posts: 547

Re: How to add Description to a LASR table when loading it via code and not through Visual Analytics

@L2Fly,

 

Here is the code:

 

data _null_;
  rc=metadata_setattr("omsobj:PhysicalTable?@Name='<REPLACE_WITH_TABLE_NAME>'","Desc","<YOUR_COMMENT>");
  put rc=;
run;
Frequent Contributor
Posts: 80

Re: How to add Description to a LASR table when loading it via code and not through Visual Analytics

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;
SAS Employee
Posts: 547

Re: How to add Description to a LASR table when loading it via code and not through Visual Analytics

@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.

Frequent Contributor
Posts: 80

Re: How to add Description to a LASR table when loading it via code and not through Visual Analytics

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;

 

Solution
‎05-02-2018 10:48 AM
SAS Employee
Posts: 547

Re: How to add Description to a LASR table when loading it via code and not through Visual Analytics

@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)
   );
Frequent Contributor
Posts: 80

Re: How to add Description to a LASR table when loading it via code and not through Visual Analytics

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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