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
-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)
);
Here is the code:
data _null_;
rc=metadata_setattr("omsobj:PhysicalTable?@Name='<REPLACE_WITH_TABLE_NAME>'","Desc","<YOUR_COMMENT>");
put rc=;
run;
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;
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.
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;
-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)
);
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
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.