18%macro irmst_export_mip_udl(
21 outpath = %sysfunc(pathname(work)),
36 %
if %quote(&model_group_sk) eq %then
41 url = &mipurl/rest/modelGroups,
43 tgt_ticket = %superq(tgt_ticket),
44 outVarTicket = service_ticket,
45 %
if %qupcase(&debug) ne NO %then
51 filename mgsjson temp;
53 proc http url =
"&mipurl/rest/modelGroups?%str(&)ticket=&service_ticket"
57 %
if %qupcase(&debug) ne NO %then
61 headers
"Accept" =
"application/json"
62 "Content-Type" =
"application/json";
65 libname mgs_json JSON fileref = mgsjson;
68 select
id into :model_group_sk1-
73 filename mgsjson clear;
74 libname mgs_json clear;
76 %let num_models = &sqlobs;
78 %
do i = 1 %to &num_models;
79 %put NOTE: Extracting model group &i of &num_models: &&model_group_sk&i..;
80 %irmst_export_mip_udl(
81 chunk_size = &chunk_size,
82 model_group_sk = &&model_group_sk&i,
86 mipurl = %superq(mipurl),
87 tgt_ticket = %superq(tgt_ticket)
93 %
do j = 1 %to %sysfunc(countw(&model_group_sk));
95 %let model_group_sk&j = %scan(&model_group_sk, &j);
100 %irm_rest_get_ticket(
101 url = &mipurl/rest/modelGroups/&&model_group_sk&j,
103 tgt_ticket = %superq(tgt_ticket),
104 outVarTicket = service_ticket,
105 %
if %qupcase(&debug) ne NO %then
111 filename mgjson temp;
113 proc http url =
"&mipurl/rest/modelGroups/&&model_group_sk&j?%str(&)ticket=&service_ticket"
117 %
if %qupcase(&debug) ne NO %then
121 headers
"Accept" =
"application/json"
122 "Content-Type" =
"application/json";
125 libname mg_json JSON fileref = mgjson;
128 select length(code) into :length trimmed
134 %put ERROR: MODEL_GROUP_SK &&model_group_sk&j was not found.;
142 create table work.udl_file as
143 %
do i = 0 %to %sysfunc(floor(%sysevalf(&length/&chunk_size)));
144 select substr(code,&i*&chunk_size+1,&chunk_size) as udl_file
146 %
if &i ne %sysfunc(floor(%sysevalf(&length/&chunk_size))) %then
151 select name into :model_group_nm trimmed
155 filename mgjson clear;
156 libname mg_json clear;
161 filename _udlfile
"&outpath&pathsep&model_group_nm..sas";
163 set work.udl_file end=last;
164 file _udlfile lrecl=32767 termstr=lf;
165 put udl_file $char&chunk_size.. @;
167 filename _udlfile clear;
174 %local vars_to_delete;
177 into : vars_to_delete
180 where scope eq
'GLOBAL' and
181 (upcase(name) like
'MGS_JSON_%' or
182 upcase(name) like
'MG_JSON_%');
185 %
if vars_to_delete ne %then
187 %put NOTE: Deleting variable(s) &vars_to_delete.;
188 %symdel &vars_to_delete.;
191%mend irmst_export_mip_udl;