SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_script_credit_risk.sas
1/* ********************************************* */
2/* Credit Risk Analysis: Input Parameters */
3/* ********************************************* */
4
5/* TGT Authentication Ticket */
6%let rgf_tgt_ticket = ${globals.ticket};
7
8/* Get the root location of the SAS Risk Workgroup Application */
9%let sas_risk_workgroup_dir = ${globals.sas_risk_workgroup_dir};
10
11/* Cycle Id */
12%let cycle_id = ${context.cycle.key};
13
14/* Analysis Run Id */
15%let analysis_run_id = ${context.analysisRun.key};
16
17/* IRM Configuration Set Id */
18%let config_set_id = ${params.CONFIGSETID};
19
20/* Portfolio key */
21%let portfolio_key = ${params.PORTFOLIO.key};
22
23/* Counterparty key */
24%let counterparty_key = ${params.CREDITMODEL.params.COUNTERPARTY.key};
25
26/* Mitigant key */
27%let mitigant_key = ${params.CREDITMODEL.params.MITIGATION.key};
28
29/* Collateral key */
30%let collateral_key = ${params.CREDITMODEL.params.COLLATERAL.key};
31
32/*Economic Simulation key*/
33%let econsimulation_key = ${params.CREDITMODEL.params.ECONSIMULATION.key};
34
35/* IA data key */
36%let ia_data_key = ${params.IADATA.key};
37/* Model Input DataMap key */
38%let modelIn_dataMap_key = ${params.MODELINPUTMAP.key};
39
40/* Model Output DataMap key */
41%let modelOut_dataMap_key = ${params.MODELOUTPUTMAP.key};
42
43/* Model Run Key */
44%let model_run_key = ${params.CREDITMODEL.rels("context").modelRun.key};
45
46/* Keep MIP Cube? */
47%let keep_mip_cube_flg = ${params.KEEPMIPCUBE};
48
49/* LASR load method (Append/Replace) */
50%let lasr_load_method = ${params.LASRLOADMETHOD};
51
52/* List of analysis data objecs to reload (if lasr_load_method = replace) */
53%let reload_key_list = ${params.RELOADKEYLIST};
54/* Convert to space separated list: ["<key1>","<key2>",...,"<keyN>"] --> <key1> <key2> ... <keyN> */
55%let reload_key_list = %sysfunc(prxchange(s/\W+/ /i, -1, %superq(reload_key_list)));
56
57/* Process BEP x MRS parameters */
58${function:ProcessModelParameter(params.BEP, "BEP", "MRS")}
59
60/* Log Level: 1-4 */
61%let log_level = ${params.LOGLEVEL};
62
63/* Maximum wait time for IRM job completion: <number of seconds> */
64%let max_wait = ${params.MAXWAIT};
65
66/* ********************************************* */
67
68/* Initialize the environment */
69%include "&sas_risk_workgroup_dir./groups/Public/SASRiskManagementCore/cycles/&cycle_id./init.sas" / lrecl = 32000 source2;
70
71/* Set logging options (based on the value of LOG_LEVEL macro variable) */
72%irm_set_logging_options();
73
74
75/* Set Instance Parameters */
76%let jobflow_category = Analytics;
77%let jobflow_type = %lowcase(irm&solutionId._credit_risk);
78%let instance_date = %sysfunc(date(), yymmddp10.);
79%let instance_time = %sysfunc(prxchange(s/(\d+):(\d+):(\d+)/$1h$2m$3s/i, -1, %sysfunc(time(), tod8.)));
80%let instanceName = Credit Risk Analysis &instance_date._&instance_time.;
81%let instanceDesc = Credit Risk Analysis;
82
83/* Process LASR load method */
84%let reload_lasr_flg = %irmc_process_lasr_load_method(&lasr_load_method.);
85
86/* Run option table */
87data work.run_option;
88 length
89 config_name $32.
90 config_value $10000.
91 ;
92 config_name = "RMC_FA_ID"; config_value = "&rmc_fa_id."; output;
93 config_name = "CYCLE_ID"; config_value = "&cycle_id."; output;
94 config_name = "ANALYSIS_RUN_ID"; config_value = "&analysis_run_id."; output;
95 config_name = "ANALYSIS_TYPE"; config_value = "SCR"; output;
96 config_name = "MAX_WAIT"; config_value = "&max_wait."; output;
97 config_name = "LOG_LEVEL"; config_value = "&log_level."; output;
98 config_name = "RELOAD_LASR_FLG"; config_value = "&reload_lasr_flg."; output;
99 config_name = "RELOAD_KEY_LIST"; config_value = "&reload_key_list."; output;
100 config_name = "TGT_TICKET"; config_value = "&rgf_tgt_ticket."; output;
101run;
102
103/* Credit Stress parameters table */
104data work.credit_risk_config;
105 length
106 config_name $32.
107 config_value $100.
108 ;
109 config_name = "CREDIT_MODEL_RUN_KEY"; config_value = "&model_run_key."; output;
110 config_name = "PORTFOLIO_KEY"; config_value = "&portfolio_key."; output;
111 config_name = "COUNTERPARTY_KEY"; config_value = "&counterparty_key."; output;
112 config_name = "MITIGANT_KEY"; config_value = "&mitigant_key."; output;
113 config_name = "COLLATERAL_KEY"; config_value = "&collateral_key."; output;
114 config_name = "ECONSIMULATION_KEY"; config_value = "&econsimulation_key."; output;
115 config_name = "IA_DATA"; config_value = "&ia_data_key."; output;
116 config_name = "MODELIN_DATAMAP_KEY"; config_value = "&modelIn_dataMap_key."; output;
117 config_name = "MODELOUT_DATAMAP_KEY"; config_value = "&modelOut_dataMap_key."; output;
118 config_name = "KEEP_MIP_CUBE_FLG"; config_value = "&keep_mip_cube_flg."; output;
119run;
120
121
122%let httpSuccess=1;
123data bep_x_mrs_config;
124 length BEP_KEY MRS_KEY 8.;
125 keep BEP_KEY MRS_KEY;
126 bep_cnt = symgetn("BEP_CNT");
127 do n = 1 to bep_cnt;
128 bep_key = symgetn(cats("BEP_", n));
129 mrs_cnt = symgetn(cats("BEP_", n, "_MRS_CNT"));
130 if mrs_cnt <= 0 then do;
131 put "ERROR: No Master Risk Scenarios have been assigned to Business Evolution Plan Id " bep_key;
132 call symput("httpSuccess", 0);
133 stop;
134 end;
135 do i = 1 to mrs_cnt;
136 mrs_key = symgetn(cats("BEP_", n, "_MRS_", i));
137 output;
138 end;
139 end;
140run;
141
142%macro check_httpSuccess;
143 %if &httpSuccess. ne 1 %then %do;
144 %abort cancel;
145 %end;
146%mend check_httpSuccess;
147%check_httpSuccess;
148
149
150
151%let instanceKey =;
152%let jobflow_status = Unknown;
153/* Create job flow instance and wait for completion */
154%irm_rest_create_jobflow_instance(instance_name = &instanceName.
155 , description = &instanceDesc.
156 , entityId = &entity_id.
157 , entityRoleKey = &entity_role_key.
158 , category = &jobflow_category.
159 , jobflowFile = &jobflow_type.
160 , baseDate = &irm_base_dt.
161 , configSetId = &config_set_id.
162 , federatedAreaID = &irm_fa_id.
163 , sourceFederatedAreaId = &irm_fa_id.
164 , src_param_tables = work.run_option work.credit_risk_config
165 , tgt_param_tables = &solutionLibrefPrefix._CFG.RUN_OPTION &solutionLibrefPrefix._CFG.CREDIT_RISK_CONFIG
166 , src_upload_tables = work.bep_x_mrs_config
167 , tgt_upload_tables = &solutionLibrefPrefix._CFG.BEP_X_MRS_CONFIG
168 , autoRun = true
169 , wait_flg = Y
170 , pollInterval = 3
171 , maxWait = &max_wait.
172 , host = &irm_protocol.://&irm_host.
173 , port = &irm_port.
174 , tgt_ticket = &rgf_tgt_ticket.
175 , outvar = instanceKey
176 , outVarStatus = jobflow_status
177 );
178
179%if(&jobflow_status. = Successful) %then %do;
180 /* Refresh the Star Schema Views */
181 %irmc_refresh_lasr_schema_view(lasr_lib = &lasr_libref.
182 , mart_table_name = &solutionId._CREDIT_RISK_DETAIL
183 , rls_table_name = &solutionId._CREDIT_RISK_DETAIL_RLS
184 , meta_repository = &meta_repository.
185 , lasr_library_name = &lasr_library_name.
186 , lasr_meta_folder = &lasr_meta_folder.
187 );
188%end;
189
190/* Update the Cycle control table */
191%irmc_update_ctrl_table(cycle_id = &cycle_id.
192 , analysis_run_id = &analysis_run_id.
193 , dr_libref = &dr_libref.
194 , entry_type = IRM
195 , entry_id = &instanceKey.
196 , entry_name = &instanceName.
197 );