SAS Enterprise Guide – Load to LASR Task Code

/*The copyright to this code belongs to SAS Institute. */
/*This code is from the SAS Enterprise Guide 7.11 Load to LASR task */
/*This code is shown for demostration purposes only and may not work with your installation. */
/*Contact SAS Technical Support or you local SAS administrator if you need help. */
/* Status Checkpoint Macro */
%macro statuscheckpoint(maxokstatus=4, varstocheck=SYSERR SYSLIBRC );
 %GLOBAL LASTSTEPRC;
 %LET pos=1;
 %let var=notset;
 %let var=%SCAN(&varstocheck.,&pos.);
 %DO %WHILE ("&VAR." ne ""); 
 /* Retrieve the next return code to check */ 
 %if (%symexist(&VAR.)) %then %do; 
 %let val=&&&VAR..; 
 %if (("&VAL." ne "") and %eval(&VAL. > &maxokstatus.)) %then %do; 
 %put FAIL = &VAR.=&VAL. / SYSCC=&SYSCC.; 
 %let LASTSTEPRC=&VAL.; 
 %end; 
 %end; 
 %let pos = %eval(&pos.+1); 
 %let var=%SCAN(&varstocheck.,&pos.); 
 %END; 
%mend;
/*Load Data Macro */
%macro codeBody;
 %GLOBAL LASTSTEPRC;
 LIBNAME LASRLIB META Library="Visual Analytics Public LASR" METAOUT=DATA;
/* Remove existing table from LASR if loaded already */ 
 %macro deletedsifexists(lib,name);
 %if %sysfunc(exist(&lib..&name.)) %then %do;
 proc datasets library=&lib. nolist;
 delete &name.;
 quit;
 %end;
 %mend deletedsifexists;
%deletedsifexists(LASRLIB, AREA_GEOPLOT);
 LIBNAME LASRLIB META Library="Visual Analytics Public LASR"; 
 LIBNAME VAPUBLIC 'WORK' loglib=yes;
/* Optimize Load With PROC LASR */
 proc lasr port=10031
 data=VAPUBLIC.AREA_GEOPLOT ( )
 signer="https://myserver-address-was-here.com:7980/SASLASRAuthorization"
 add noclass;
 performance
 host="myserver-address-was-here.com";
 run;
%mend;
%codeBody;
%statuscheckpoint;
/* Register Table Macro */
%macro registertable( REPOSITORY=Foundation, REPOSID=, LIBRARY=, TABLE=, FOLDER=, TABLEID=, PREFIX= );
 %if %symexist(LASTSTEPRC) %then %do;
 %if %eval(&LASTSTEPRC. <= 4) %then %do;
 /* 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 ('AREA_GEOPLOT'); 
 run; 
 quit;
 %end;
 %end;
%mend;
%registerTable(
 LIBRARY=%nrstr(/Shared Data/SAS Visual Analytics/Public/Visual Analytics Public LASR)
 , FOLDER=%nrstr(/Shared Data/SAS Visual Analytics/Public/LASR)
 );
%LET LASTSTEPRC=0;
FOOTNOTE;