12%let rgf_tgt_ticket = ${globals.ticket};
15%let sas_risk_workgroup_dir = ${globals.sas_risk_workgroup_dir};
18%let cycle_id = ${context.cycle.key};
21%let analysis_run_id = ${context.analysisRun.key};
24%let config_set_id = ${params.CONFIGSETID};
27%let portfolio_key = ${params.PORTFOLIO.key};
30%let model_run_key = ${params.CREDITMODEL.rels(
"context").modelRun.key};
33%let counterparty_key = ${params.CREDITMODEL.params.COUNTERPARTY.key};
36%let mitigant_key = ${params.CREDITMODEL.params.MITIGATION.key};
39%let collateral_key = ${params.CREDITMODEL.params.COLLATERAL.key};
42%let econsimulation_key = ${params.CREDITMODEL.params.ECONSIMULATION.key};
46%let ia_data_key = ${params.IADATA.key};
49%let modelIn_dataMap_key = ${params.MODELINPUTMAP.key};
52%let modelOut_dataMap_key = ${params.MODELOUTPUTMAP.key};
55%let tm_results_key = ${params.TRANSITIONMATRIXRESULTS.key};
58%let query_all_hrz_flg = ${params.QUERYALLHRZ};
61%let atm_overlay = ${params.ATMOVERLAY};
62%
if &atm_overlay eq Y %then %
do;
64 %let scenario_prompt = ${params.SCENARIOTOOVERLAY};
66 %let scenario_to_overlay = %sysfunc(prxchange(s/[\[\]]
69 ${function:ProcessSpreadsheetParameter(params.ATMUPLOAD,
"ATMUPLOAD")}
73%
if &query_all_hrz_flg. = Y %then %
do;
74 %let keep_mip_cube_flg = Y;
77 %let keep_mip_cube_flg = ${params.KEEPMIPCUBE};
81%let lasr_load_method = ${params.LASRLOADMETHOD};
85%let reload_key_list = ${params.RELOADKEYLIST};
87%let reload_key_list = %sysfunc(prxchange(s/\W+/ /i, -1, %superq(reload_key_list)));
90%let log_level = ${params.LOGLEVEL};
93%let max_wait = ${params.MAXWAIT};
98%include
"&sas_risk_workgroup_dir./groups/Public/SASRiskManagementCore/cycles/&cycle_id./init.sas" / lrecl = 32000 source2;
101%irm_set_logging_options();
104%let reload_lasr_flg = %irmc_process_lasr_load_method(&lasr_load_method.);
110%irm_rest_get_rgf_analysis_run(host = &rgf_protocol.:
111 , server = &rgf_service.
112 , solution = &rgf_solution.
114 , tgt_ticket = %superq(rgf_tgt_ticket)
115 , filter = filter=hasObjectLinkTo(%str(%
')%upcase(&rgf_solution.)%str(%'),
'analysisData_analysisRun_out',&tm_results_key.,0)
116 , outds = analysis_run
117 , outds_params = analysis_run_params
118 , outVarTicket = ticket
119 , outSuccess = httpSuccess
120 , outResponseStatus = responseStatus
126 set analysis_run_params;
127 where upcase(parameterName) eq
"BEP";
128 call symputX(
'BEP',parameterValue);
134 local json = require
'sas.risk.utils.json'
135 local BEPstr =
'{"rows":'..sas.symget(
'BEP')..
'}'
136 local BEPtbl = json:decode(BEPstr)
137 local bep_cnt = #BEPtbl.rows
138 sas.symput(
'BEP_CNT',bep_cnt)
139 for i,bep in ipairs(BEPtbl.rows) do
140 local bepKey = bep.handle:gsub(".-|(%d+)|.*","%1")
141 sas.symput('BEP_'..i,bepKey);
142 local bep_mrs_cnt =
#bep.dependencies;
143 sas.symput(
'BEP_'..i..
'_MRS_CNT',bep_mrs_cnt)
144 for j,scen in ipairs(bep.dependencies) do
145 local scenKey = scen.handle:gsub(".-|(%d+)|.*","%1")
146 sas.symput('BEP_'..i..'_MRS_'..j,scenKey)
153data bep_x_mrs_config;
154 length BEP_KEY MRS_KEY 8.;
155 keep BEP_KEY MRS_KEY;
156 bep_cnt = symgetn("BEP_CNT");
158 bep_key = symgetn(cats("BEP_", n));
159 mrs_cnt = symgetn(cats("BEP_", n, "_MRS_CNT"));
161 mrs_key = symgetn(cats("BEP_", n, "_MRS_", i));
165 put "WARNING: No Master Risk Scenarios have been assigned to Business Evolution Plan Id " bep_key;
172%let segment_lvl_analysis_run_key=;
174 set work.analysis_run;
175 call symputx('segment_lvl_analysis_run_key',objectId);
179%let data_prep_out_portfolio_key=;
182 set analysis_run_params;
183 if parameterName eq 'PORTFOLIO' then
184 call symputX('portParmStr',parameterValue);
189 local JSON = require 'risk.common.json'
190 local portParmTbl = JSON:decode(sas.symget('portParmStr'))
191 local portKey = portParmTbl.handle:gsub(".-|(%d+)|.*","%1")
192 sas.symput('data_prep_out_portfolio_key',portKey)
197%let jobflow_category = Analytics;
198%let jobflow_type = %lowcase(irm&solutionId._credit_risk);
199%let instance_date = %sysfunc(date(), yymmddp10.);
200%let instance_time = %sysfunc(prxchange(s/(\d+):(\d+):(\d+)/$1h$2m$3s/i, -1, %sysfunc(time(), tod8.)));
201%let instanceName = Credit Risk Analysis &instance_date._&instance_time.;
202%let instanceDesc = Credit Risk Analysis;
207%if &atm_overlay eq Y %then %do;
210 %let ad_name_tm_overlay = Transition Matrix Results with ATM Overlay;
211 %let ad_desc_tm_overlay = Transition Matrix Results with ATM Overlay from Analysis Run &analysis_run_id.. Created by &_metauser on %sysfunc(datetime(), nldatmw200.);
214 %irm_rgf_retrieve_analysis_data(key = &tm_results_key.
217 , outds_dataInfo = tm_dataInfo
218 , outds_dataDef = tm_dataDef
219 , host = &rgf_protocol.:
220 , server = &rgf_service.
221 , solution = &rgf_solution.
223 , tgt_ticket = %superq(rgf_tgt_ticket)
224 , outVarTicket = ticket_upload
225 , outSuccess = httpSuccess
226 , outResponseStatus = responseStatus
234 call symputx("schemaName", schemaName, "L");
235 call symputx("schemaVersion", schemaVersion, "L");
241 into :tm_model_groups separated by ' '
247 %irmst_import_atm_spreadsheet(atmupload = work.atmupload
248 , outds = work.atm_outds
249 , in_model_groups = &tm_model_groups.
255 %irmst_run_atm_overlay(in_model_tm_results = tm_orig
256 , in_atm_upload = work.atm_outds
257 , scenario_to_overlay = %superq(scenario_to_overlay)
259 , analysis_data_name = &ad_name_tm_overlay.
260 , analysis_data_desc = %quote(&ad_name_tm_overlay.)
261 , analysis_run_id = &analysis_run_id
262 , base_date = &base_dt
263 , cycle_id = &cycle_id
264 , status_cd = Preliminary
265 , visibility_cd = Private
267 , libref = &dr_libref
268 , schema_name = &schemaName.
269 , schema_version = &schemaVersion.
270 , entity_id = &entity_id.
272 , out_atm_results_key_var = atm_results_key
273 , out_exceptions = work._atm_upload_exceptions
274 , out_analysis_data = work._atm_upload_analysis_data
275 , out_partition_list = work._atm_upload_partition_list
276 , out_data_definition = work._atm_upload_data_definition
277 , out_link_instance = work._atm_upload_link_instance
279 , host = &rgf_protocol.:
280 , server = &rgf_service.
281 , solution = &rgf_solution.
283 , tgt_ticket = %superq(rgf_tgt_ticket)
288%if %symexist(atm_results_key) and
289 %superq(atm_results_key) ne %then
291 %let tm_results_key = &atm_results_key;
300 config_name = "RMC_FA_ID"; config_value = "&rmc_fa_id."; output;
301 config_name = "CYCLE_ID"; config_value = "&cycle_id."; output;
302 config_name = "ANALYSIS_RUN_ID"; config_value = "&analysis_run_id."; output;
303 config_name = "ANALYSIS_TYPE"; config_value = "CCAR_SCR"; output;
304 config_name = "MAX_WAIT"; config_value = "&max_wait."; output;
305 config_name = "LOG_LEVEL"; config_value = "&log_level."; output;
306 config_name = "RELOAD_LASR_FLG"; config_value = "&reload_lasr_flg."; output;
307 config_name = "RELOAD_KEY_LIST"; config_value = "&reload_key_list."; output;
308 config_name = "TGT_TICKET"; config_value = "&rgf_tgt_ticket."; output;
309 config_name = "SEGMENT_LVL_ANALYSIS_RUN_KEY"; config_value = "&segment_lvl_analysis_run_key."; output;
313data work.credit_risk_config;
318 config_name = "TM_RESULTS_KEY"; config_value = "&tm_results_key."; output;
319 config_name = "QUERY_ALL_HRZ_FLG"; config_value = "&query_all_hrz_flg."; output;
320 config_name = "DATA_PREP_OUT_PORTFOLIO_KEY"; config_value = "&data_prep_out_portfolio_key"; output;
322 %let dma_expansion_flg = Y;
323 config_name = "DMA_EXPANSION_FLG"; config_value = "&dma_expansion_flg"; output;
325 config_name = "CREDIT_MODEL_RUN_KEY"; config_value = "&model_run_key."; output;
326 config_name = "PORTFOLIO_KEY"; config_value = "&portfolio_key."; output;
327 config_name = "COUNTERPARTY_KEY"; config_value = "&counterparty_key."; output;
328 config_name = "MITIGANT_KEY"; config_value = "&mitigant_key."; output;
329 config_name = "COLLATERAL_KEY"; config_value = "&collateral_key."; output;
330 config_name = "ECONSIMULATION_KEY"; config_value = "&econsimulation_key."; output;
331 config_name = "IA_DATA"; config_value = "&ia_data_key."; output;
332 config_name = "MODELIN_DATAMAP_KEY"; config_value = "&modelIn_dataMap_key."; output;
333 config_name = "MODELOUT_DATAMAP_KEY"; config_value = "&modelOut_dataMap_key."; output;
334 config_name = "KEEP_MIP_CUBE_FLG"; config_value = "&keep_mip_cube_flg."; output;
339%let responseStatus = ;
342%let jobflow_status = Unknown;
344%irm_rest_create_jobflow_instance(instance_name = &instanceName.
345 , description = &instanceDesc.
346 , entityId = &entity_id.
347 , entityRoleKey = &entity_role_key.
348 , category = &jobflow_category.
349 , jobflowFile = &jobflow_type.
350 , baseDate = &irm_base_dt.
351 , configSetId = &config_set_id.
352 , federatedAreaID = &irm_fa_id.
353 , sourceFederatedAreaId = &irm_fa_id.
354 , src_param_tables = work.run_option work.credit_risk_config
355 , tgt_param_tables = &solutionLibrefPrefix._CFG.RUN_OPTION &solutionLibrefPrefix._CFG.CREDIT_RISK_CONFIG
356 , src_upload_tables = work.bep_x_mrs_config
357 , tgt_upload_tables = &solutionLibrefPrefix._CFG.BEP_X_MRS_CONFIG
361 , maxWait = &max_wait.
362 , host = &irm_protocol.:
364 , tgt_ticket = &rgf_tgt_ticket.
365 , outvar = instanceKey
366 , outVarStatus = jobflow_status
369%if(&jobflow_status. = Successful) %then %do;
371 %irmc_refresh_lasr_schema_view(lasr_lib = &lasr_libref.
372 , mart_table_name = &solutionId._CREDIT_RISK_DETAIL
373 , rls_table_name = &solutionId._CREDIT_RISK_DETAIL_RLS
374 , meta_repository = &meta_repository.
375 , lasr_library_name = &lasr_library_name.
376 , lasr_meta_folder = &lasr_meta_folder.
379 %irmc_refresh_lasr_schema_view(lasr_lib = &lasr_libref.
380 , mart_table_name = &solutionId._MIGRATION_DETAIL
381 , rls_table_name = &solutionId._MIGRATION_DETAIL_RLS
382 , meta_repository = &meta_repository.
383 , lasr_library_name = &lasr_library_name.
384 , lasr_meta_folder = &lasr_meta_folder.
389%irmc_update_ctrl_table(cycle_id = &cycle_id.
390 , analysis_run_id = &analysis_run_id.
391 , dr_libref = &dr_libref.
393 , entry_id = &instanceKey.
394 , entry_name = &instanceName.