38%local _sysopts base_uri caslib uuid server
39 srcfile srccaslib fname1 libref1 ftmp i _svcount;
40%let _sysopts=%sysfunc(getoption(mprint)) %sysfunc(getoption(notes));
44 iftrue=(
"&lib"=
"" or
"&table"=
""),
45 msg=%str(lib= and table= are required)
48%
if &mdebug=1 %then %
do;
57 where=(libname=
"%upcase(&lib)"
58 and sysname in (
"Caslib",
"Session UUID"))
60 if sysname=
"Caslib" then call symputx(
'caslib',sysvalue,
'L');
61 else call symputx(
'uuid',sysvalue,
'L');
65 iftrue=(
"&caslib"=
""),
66 msg=%str(&lib is not an assigned CAS libref)
71 msg=%str(No session UUID found
for libref &lib)
74%
if &mdebug=1 %then %
do;
79%let base_uri=%mf_getplatform(VIYARESTAPI);
82%let fname1=%mf_getuniquefileref();
83%let libref1=%mf_getuniquelibref();
85proc http method=
'GET' out=&fname1 oauth_bearer=sas_services
86 url=
"&base_uri/casManagement/servers";
90 iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200),
91 msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
94libname &libref1 JSON fileref=&fname1;
98 call symputx(cats(
'_sv_', _n_), name,
'L');
99 call symputx(
'_svcount', _n_,
'L');
102libname &libref1 clear;
103filename &fname1 clear;
106%
do i=1 %to &_svcount;
107 %
if "&server"=
"" %then %
do;
108 %
if &mdebug=1 %then %put checking server: &&_sv_&i;
109 %let ftmp=%mf_getuniquefileref();
110 proc http method=
'GET' out=&ftmp oauth_bearer=sas_services
111 url=
"&base_uri/casManagement/servers/&&_sv_&i/sessions/&uuid";
113 %
if &SYS_PROCHTTP_STATUS_CODE=200
114 %then %let server=&&_sv_&i;
115 filename &ftmp clear;
120 iftrue=(
"&server"=
""),
121 msg=%str(Could not find owning server
for CAS session &uuid)
124%
if &mdebug=1 %then %put &=server;
127%let fname1=%mf_getuniquefileref();
128%let libref1=%mf_getuniquelibref();
130proc http method=
'GET' out=&fname1 oauth_bearer=sas_services
131 url=
"&base_uri/casManagement/servers/&server/caslibs/&caslib/tables/&table";
134%
if &mdebug=1 %then %
do;
135 %put &=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
144 iftrue=(&SYS_PROCHTTP_STATUS_CODE=404),
145 msg=%str(&caslib..&table not found - is it loaded in memory?)
148 iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200),
149 msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
152libname &libref1 JSON fileref=&fname1;
155 set &libref1..tablereference;
156 call symputx(
'srcfile', sourceTableName,
'L');
157 call symputx(
'srccaslib', sourceCaslibName,
'L');
161libname &libref1 clear;
162filename &fname1 clear;
165 iftrue=(
"&srcfile"=
"" or
"&srccaslib"=
""),
166 msg=%str(No sourceTableName/sourceCaslibName
for &caslib..&table)
169%
if &mdebug=1 %then %put &=srcfile;
173 save casdata=
"&table"
176 outcaslib=
"&srccaslib"
181 iftrue=(&syscc ne 0),
182 msg=%str(Save failed
for &caslib..&table)
185%put NOTE: Table &caslib..&table saved to &srcfile;
188%
if &mdebug=1 %then %
do;