6%let rgf_tgt_ticket = ${globals.ticket};
9%let sas_risk_workgroup_dir = ${globals.sas_risk_workgroup_dir};
12%let cycle_id = ${context.cycle.key};
15%let analysis_run_id = ${context.analysisRun.key};
18%let config_set_id = ${params.CONFIGSETID};
21%let portfolio_key = ${params.PORTFOLIO.key};
24%let counterparty_key = ${params.ECVARMODEL.params.COUNTERPARTY.key};
27%let mitigant_key = ${params.ECVARMODEL.params.MITIGATION.key};
30%let collateral_key = ${params.ECVARMODEL.params.COLLATERAL.key};
33%let econsimulation_key = ${params.ECVARMODEL.params.ECONSIMULATION.key};
36%let risk_type = ${params.RISKTYPE};
39%let ia_data_key = ${params.IADATA.key};
41%let modelIn_dataMap_key = ${params.MODELINPUTMAP.key};
44%let modelOut_dataMap_key = ${params.MODELOUTPUTMAP.key};
47%let model_run_key = ${params.ECVARMODEL.rels(
"context").modelRun.key};
50%let keep_mip_cube_flg = ${params.KEEPMIPCUBE};
53%let lasr_load_method = ${params.LASRLOADMETHOD};
56%let reload_key_list = ${params.RELOADKEYLIST};
58%let reload_key_list = %sysfunc(prxchange(s/\W+/ /i, -1, %superq(reload_key_list)));
61${function:ProcessModelParameter(params.BEP,
"BEP",
"MRS")}
64%let log_level = ${params.LOGLEVEL};
67%let max_wait = ${params.MAXWAIT};
70%let load_external = ${params.LOADEXTERNAL};
73%let extBaseScen_sn = ${params.EXTBASECASESCEN.mrsShortName};
74%let extAdverseScen_sn = ${params.EXTADVERSESCEN.mrsShortName};
75%let extBEP_sn = ${params.EXTBEP.bepShortName};
77${function:ProcessSpreadsheetParameter(params.EXTBASECASERESULTS,
"extBaseResults")}
78${function:ProcessSpreadsheetParameter(params.EXTADVERSERESULTS,
"extAdverseResults")}
84%include
"&sas_risk_workgroup_dir./groups/Public/SASRiskManagementCore/cycles/&cycle_id./init.sas" / lrecl = 32000 source2;
87%irm_set_logging_options();
90%let analysis_run_type = EC;
91%let jobflow_category = Analytics;
92%
if &risk_type.=Credit %then %
do;
93 %let jobflow_type = %lowcase(irm&solutionId._credit_risk);
94 %let instanceName = Credit Risk Analysis &instance_date._&instance_time.;
95 %let instanceDesc = Credit Risk Analysis;
97%
if &risk_type.=Market %then %
do;
98 %let analysis_run_type = EC_MARKET;
99 %let jobflow_type = %lowcase(irm&solutionId._market_risk);
100 %let instanceName = Market Risk Analysis &instance_date._&instance_time.;
101 %let instanceDesc = Market Risk Analysis;
103%let instance_date = %sysfunc(date(), yymmddp10.);
104%let instance_time = %sysfunc(prxchange(s/(\d+):(\d+):(\d+)/$1h$2m$3s/i, -1, %sysfunc(time(), tod8.)));
105%let jobflow_status = Unknown;
106%
if(&load_external. = No) %then %
do;
109 %let reload_lasr_flg = %irmc_process_lasr_load_method(&lasr_load_method.);
112 data work.run_option;
117 config_name =
"RMC_FA_ID"; config_value =
"&rmc_fa_id."; output;
118 config_name =
"CYCLE_ID"; config_value =
"&cycle_id."; output;
119 config_name =
"ANALYSIS_RUN_ID"; config_value =
"&analysis_run_id."; output;
120 config_name =
"ANALYSIS_TYPE"; config_value =
"&analysis_run_type."; output;
121 config_name =
"MAX_WAIT"; config_value =
"&max_wait."; output;
122 config_name =
"LOG_LEVEL"; config_value =
"&log_level."; output;
123 config_name =
"RELOAD_LASR_FLG"; config_value =
"&reload_lasr_flg."; output;
124 config_name =
"RELOAD_KEY_LIST"; config_value =
"&reload_key_list."; output;
125 config_name =
"TGT_TICKET"; config_value =
"&rgf_tgt_ticket."; output;
129 data work.credit_risk_config;
134 config_name =
"CREDIT_MODEL_RUN_KEY"; config_value =
"&model_run_key."; output;
135 config_name =
"PORTFOLIO_KEY"; config_value =
"&portfolio_key."; output;
136 config_name =
"COUNTERPARTY_KEY"; config_value =
"&counterparty_key."; output;
137 config_name =
"MITIGANT_KEY"; config_value =
"&mitigant_key."; output;
138 config_name =
"COLLATERAL_KEY"; config_value =
"&collateral_key."; output;
139 config_name =
"ECONSIMULATION_KEY"; config_value =
"&econsimulation_key."; output;
140 config_name =
"IA_DATA"; config_value =
"&ia_data_key."; output;
141 config_name =
"MODELIN_DATAMAP_KEY"; config_value =
"&modelIn_dataMap_key."; output;
142 config_name =
"MODELOUT_DATAMAP_KEY"; config_value =
"&modelOut_dataMap_key."; output;
143 config_name =
"KEEP_MIP_CUBE_FLG"; config_value =
"&keep_mip_cube_flg."; output;
144 config_name =
"MART_TABLE_NAME"; config_value =
"VALUE_AT_RISK_DETAIL"; output;
148 data bep_x_mrs_config;
149 length BEP_KEY MRS_KEY 8.;
150 keep BEP_KEY MRS_KEY;
151 bep_cnt = symgetn(
"BEP_CNT");
153 bep_key = symgetn(cats(
"BEP_", n));
154 mrs_cnt = symgetn(cats(
"BEP_", n,
"_MRS_CNT"));
155 if mrs_cnt <= 0 then
do;
156 put
"ERROR: No Master Risk Scenarios have been assigned to Business Evolution Plan Id " bep_key;
157 call symput(
"httpSuccess", 0);
161 mrs_key = symgetn(cats(
"BEP_", n,
"_MRS_", i));
167 %macro check_httpSuccess;
168 %
if &httpSuccess. ne 1 %then %
do;
171 %mend check_httpSuccess;
176 %irm_rest_create_jobflow_instance(instance_name = &instanceName.
177 , description = &instanceDesc.
178 , entityId = &entity_id.
179 , entityRoleKey = &entity_role_key.
180 , category = &jobflow_category.
181 , jobflowFile = &jobflow_type.
182 , baseDate = &irm_base_dt.
183 , configSetId = &config_set_id.
184 , federatedAreaID = &irm_fa_id.
185 , sourceFederatedAreaId = &irm_fa_id.
186 , src_param_tables = work.run_option work.credit_risk_config
187 , tgt_param_tables = &solutionLibrefPrefix._CFG.RUN_OPTION &solutionLibrefPrefix._CFG.CREDIT_RISK_CONFIG
188 , src_upload_tables = work.bep_x_mrs_config
189 , tgt_upload_tables = &solutionLibrefPrefix._CFG.BEP_X_MRS_CONFIG
193 , maxWait = &max_wait.
194 , host = &irm_protocol.:
196 , tgt_ticket = &rgf_tgt_ticket.
197 , outvar = instanceKey
198 , outVarStatus = jobflow_status
201%put --- DONE CALLING JOBFLOW, STATUS IS: &jobflow_status.;
202%
if(&jobflow_status. = Successful and &load_external. = No) %then %
do;
204 %irmc_refresh_lasr_schema_view(lasr_lib = &lasr_libref.
205 , mart_table_name = &solutionId._VALUE_AT_RISK_DETAIL
206 , rls_table_name = &solutionId._VALUE_AT_RISK_DETAIL_RLS
207 , meta_repository = &meta_repository.
208 , lasr_library_name = &lasr_library_name.
209 , lasr_meta_folder = &lasr_meta_folder.
212 %irmst_create_loss_dist_summary(host = &rgf_protocol.:
213 , server = &rgf_service.
214 , solution = &rgf_solution.
216 , tgt_ticket = &rgf_tgt_ticket.
217 , name = %sysfunc(propcase(&risk_type.)) Risk
for &entity_id. Summary &instance_date._&instance_time.
218 , description = Loss Distribution Summary information
for analysis run &analysis_run_id.
219 , risktype = &risk_type.
220 , analysis_run_key = &analysis_run_id.
221 , base_date = &base_dt.
222 , cycle_id = &cycle_id.
223 , entity_id = &entity_id.
224 , status_cd = Preliminary
225 , libref = &dr_libref.
226 , schema_name = st_loss_distribution_sumry
227 , schema_version = &content_version.
228 , out_exceptions = data_exceptions
229 , out_analysis_data = out_loss_summary
230 , out_partition_list = ls_partitions
231 , out_data_definition = ls_data_def
232 , out_link_instance = ls_link_instances
233 , outVarTicket = ticket
234 , outSuccess = httpSuccess
235 , outResponseStatus = responseStatus
240%
if(&load_external. = No) %then %
do;
242 %irmc_update_ctrl_table(cycle_id = &cycle_id.
243 , analysis_run_id = &analysis_run_id.
244 , dr_libref = &dr_libref.
246 , entry_id = &instanceKey.
247 , entry_name = &instanceName.
250%
if(&load_external. = Yes) %then %
do;
252 length SCENARIO_ID $ 32;
254 RISK_TYPE =
"&risk_type.";
255 SCENARIO_ID = compress(
"&extBEP_sn._&extBaseScen_sn._FT" || put(forecastTime,BEST.));
256 REPORTING_DT= input(
"&base_dt.",YYMMDD10.);
257 drop forecastTime key;
259 data extAdverseResults;
260 length SCENARIO_ID $ 32;
261 set extAdverseResults;
262 RISK_TYPE =
"&risk_type.";
263 SCENARIO_ID = compress(
"&extBEP_sn._&extAdverseScen_sn._FT" || put(forecastTime,BEST.));
264 REPORTING_DT= input(
"&base_dt.",YYMMDD10.);
265 drop forecastTime key;
268 set extBaseResults extAdverseResults;
271 %irm_rgf_store_analysis_data(ds_in = loss_summary
273 , analysis_data_name = %sysfunc(propcase(&risk_type.)) Risk
for &entity_id. Summary &instance_date._&instance_time.
274 , analysis_data_desc = Externally produced &risk_type. risk results
275 , base_date = &base_dt.
276 , cycle_id = &cycle_id.
277 , entity_id = &entity_id.
278 , status_cd = Preliminary
279 , analysis_run_id = &analysis_run_id.
282 , libref = &dr_libref.
283 , schema_name = st_loss_distribution_sumry
284 , schema_version = &content_version.
287 , out_exceptions = data_exceptions
288 , out_analysis_data = new_analysys_data
289 , out_partition_list = new_partitions
290 , out_data_definition = data_definition
291 , out_link_instance = link_instance
294 , host = &rgf_protocol.:
295 , server = &rgf_service.
296 , solution = &rgf_solution.
298 , tgt_ticket = &rgf_tgt_ticket.
299 , outVarTicket = ticket
300 , outSuccess = httpSuccess
301 , outResponseStatus = responseStatus
305 %irmc_update_ctrl_table(cycle_id = &cycle_id.
306 , analysis_run_id = &analysis_run_id.
307 , dr_libref = &dr_libref.
309 , entry_id = &analysis_run_id.
310 , entry_name = Economic Capital
311 , entry_location = analysisRuns