28%macro irmst_build_tm_from_cube(
31 run_output_array = transmat_part,
32 function_package = mipfunc.rating_format,
34 output_tbl = work.tm_set,
49 length cmplib $32767.;
50 cmplib = getoption(
'cmplib');
51 cmplib = translate(cmplib,
'',
'(',
'',
')');
52 call symputx(
'ori_cmplib',cmplib,
'l');
58 %irm_add_function_package(
59 cmplib = &function_package.,
60 check_function = rating_num_to_grade
66 %let rwg_appdata_root_dir = %sysfunc(metadata_appprop(Risk Work Group Svr Cfg, root.dir));
71 proc hprisk task=stress
72 cube =
"&rwg_appdata_root_dir./groups/&workgroup./SASModelImplementationPlatform/output/run_instances/&mi_cube_name./results/&mi_cube_name.";
73 crossclassvars insttype;
74 output scentrans = work.&mi_cube_name. (drop = NInst
85 set work.&mi_cube_name.;
86 array arraylen{*} &run_output_array:;
87 tmdim = sqrt(dim(arraylen));
88 call symputx(
'tmdim',tmdim,
'l');
95 url = &mipurl./rest/runInstances,
97 tgt_ticket = %superq(tgt_ticket),
98 outVarTicket = service_ticket,
99 %
if %qupcase(&debug.) ne NO %then
105 filename rijson temp;
107 proc http url =
"&mipurl./rest/runInstances?%str(&)ticket=&service_ticket."
111 %
if &debug. ne NO %then
115 headers
"Accept" =
"application/json"
116 "Content-Type" =
"application/json";
119 libname ri_json JSON fileref = rijson;
122 create table work.run_instance_meta as
123 select input(
id,8.) as run_instance_sk,
128 filename rijson clear;
129 libname ri_json clear;
134 data &output_tbl (drop = scenario
139 set work.run_instance_meta;
140 set work.&mi_cube_name.;
146 call missing(mrskey);
153 %irm_build_hash_lookup(
154 hash_name = run_instance,
155 hash_table = work.run_instance_meta,
157 data_vars = run_instance_sk
160 %irm_build_hash_lookup(
161 hash_name = scenario_map,
162 hash_table = &scenario_meta.,
163 key_vars = scenarioId,
168 if upcase(scan(Scenario,-1,":")) ne "BASECASE" then
173 run_nm = scan(Scenario,1,":");
174 rc_run_instance = run_instance.find();
175 if rc_run_instance ne 0 then
177 put 'ERROR: Could not obtain run_instance_sk associated to run result.';
182 scenarioId = substr(scenario,index(scenario,':')+1);
183 rc_scenario_map = scenario_map.find();
184 if rc_scenario_map ne 0 then
186 put "ERROR: Could not obtain MRS key in the scenario metadata &scenario_meta..";
192 %do i =1 %to &tmdim.;
193 from_rating = rating_num_to_grade(&i.);
194 %do j =1 %to &tmdim.;
195 %let colname = %qcmpres(%sysfunc(rating_num_to_grade(&j.)));
196 &colname. = &run_output_array._%eval((&i.-1)*&tmdim. + &j.);
206 options cmplib=(&ori_cmplib.);
211 %if %qupcase(&debug.) eq NO %then
214 drop table work.&mi_cube_name.,
215 work.run_instance_meta;
222 %local vars_to_delete;
225 into : vars_to_delete
228 where scope eq 'GLOBAL' and
229 (upcase(name) like 'RI_JSON%');
232 %if vars_to_delete ne %then
234 %put NOTE: Deleting variable(s) &vars_to_delete.;
235 %symdel &vars_to_delete.;
238%mend irmst_build_tm_from_cube;