6%let tgt_ticket = ${globals.ticket};
9%let sas_risk_workgroup_dir = ${globals.sas_risk_workgroup_dir};
12%let cycle_key = ${context.cycle.key};
15%let cycle_name = %nrbquote(${context.cycle.name});
18%let analysis_run_key = ${context.analysisRun.key};
21%let analysis_run_name = ${context.analysisRun.name};
24%let model_run_key = ${params.AGGREGATIONMODEL.rels(
"context").modelRun.key};
27%let cap_adq_rpt_flg = ${params.CAPITALADEQUACYRPT};
30%let lasr_load_method = ${params.LASRLOADMETHOD};
33%let log_level = ${params.LOGLEVEL};
36%let adverse_scenario = ${params.ADVERSESCENARIO};
37%let basecase_scenario = ${params.BASECASESCENARIO};
39%let fsp_basecase_key = ${params.FSPBASECASE.key};
40%let fsp_adverse_key = ${params.FSPADVERSE.key};
43%let rgf_solution = ${globals.contentId};
46%let modelId = ${params.AGGREGATIONMODEL.custObj1Id};
47%let modelName = ${params.AGGREGATIONMODEL.name};
49%let run_date = %sysfunc(date(), yymmddp10.);
50%let run_time = %sysfunc(prxchange(s/(\d+):(\d+):(\d+)/$1h$2m$3s/i, -1, %sysfunc(time(), tod8.)));
53%let outDsName = ${params.OUTSUMMARYNAME};
54%
if %sysevalf(&outDsName. eq %str(),
boolean) %then %
do;
55 %let outDsName = Aggregation Results &run_date._&run_time.;
61%include
"&sas_risk_workgroup_dir./groups/Public/SASRiskManagementCore/cycles/&cycle_key./init.sas" / lrecl = 32000 source2;
64%let config_set_id = EWST;
67%irm_set_logging_options();
72%irm_get_service_info(SWCName = Risk Gov Frwk Mid-Tier
73 , DeployedComponentName = Registered SAS Application
74 , ds_out = work.rgf_info
79 call symputx("rgf_protocol", protocol, "L");
80 call symputx("rgf_host", host, "L");
81 call symputx("rgf_port", port, "L");
82 call symputx("rgf_service", ksubstr(service, 2), "L");
86%let reload_lasr_flg = %irmc_process_lasr_load_method(&lasr_load_method.);
93%irm_rest_get_rgf_model_run(host = &rgf_protocol.:
94 , server = &rgf_service.
95 , solution = &rgf_solution.
97 , tgt_ticket = &tgt_ticket.
98 , key = &model_run_key.
100 , outds_params = model_run_params
102 , outVarTicket = ticket
103 , outSuccess = httpSuccess
104 , outResponseStatus = responseStatus
108%if(not &httpSuccess. or not %rsk_dsexist(model_run)) %then %do;
109 %put ERROR: Could not retrieve model information for modelId &modelId.;
114%include fcode /source2 lrecl = 32000;
124 %if %rsk_dsexist(RISKAGG_SUMMARY_RESULTS) %then %do;
129 %let var_exist=%rsk_varexist(&out_libref..RISKAGG_SUMMARY_RESULTS, RISK_TYPE );
131 data RISKAGG_SUMMARY_RESULTS RISKAGG_SUMM_ENTITY;
132 set RISKAGG_SUMMARY_RESULTS;
133 %if &var_exist.=0 %then %do;
134 length RISK_TYPE $32.;
141 if entity_id="&entity_id." then output RISKAGG_SUMM_ENTITY;
142 output RISKAGG_SUMMARY_RESULTS;
146 %let httpSuccess = 0;
147 %let responseStatus =;
148 %irm_rgf_store_analysis_data(ds_in = RISKAGG_SUMMARY_RESULTS
150 , analysis_data_name = &outDsName.
151 , analysis_data_desc = Risk aggregation results with the &modelName. model executed on &run_date. at server time: &run_time.
152 , base_date = &base_dt.
153 , cycle_id = &cycle_key.
154 , entity_id = &entity_id.
155 , status_cd = Preliminary
156 , analysis_run_id = &analysis_run_key.
159 , libref = &dr_libref.
160 , schema_name = st_loss_distribution_sumry
161 , schema_version = &content_version.
164 , out_exceptions = data_exceptions
165 , out_analysis_data = new_analysis_data
166 , out_partition_list = new_partitions
167 , out_data_definition = data_definition
168 , out_link_instance = link_instance
171 , host = &rgf_protocol.:
172 , server = &rgf_service.
173 , solution = &rgf_solution.
175 , tgt_ticket = &tgt_ticket.
176 , outVarTicket = ticket
177 , outSuccess = httpSuccess
178 , outResponseStatus = responseStatus
182 %put ERROR: The aggregation model failed to produce a RISKAGG_SUMMARY_RESULTS dataset;
192 %if %upcase(&cap_adq_rpt_flg) = YES %then
195 %let httpSuccess = 0;
196 %let responseStatus = ;
198 %if &fsp_basecase_key. ne %str() %then %do;
200 %irm_rgf_retrieve_analysis_data(key = &fsp_basecase_key.
201 , outds = _fin_st_proj_base_dtl
202 , host = &rgf_protocol.:
203 , server = &rgf_service.
204 , solution = &rgf_solution.
206 , tgt_ticket = &tgt_ticket.
207 , outVarTicket = ticket
208 , outSuccess = httpSuccess
209 , outResponseStatus = responseStatus
214 set _fin_st_proj_base_dtl(obs=1);
215 call symputx("base_scenario", scenario_name, "L");
219 %put ERROR: The financial statement projection - basecase results dataset does not exist;
223 %let httpSuccess = 0;
224 %let responseStatus = ;
226 %if &fsp_adverse_key. ne %str() %then %do;
228 %irm_rgf_retrieve_analysis_data(key = &fsp_adverse_key.
229 , outds = _fin_st_proj_adverse_dtl
230 , host = &rgf_protocol.:
231 , server = &rgf_service.
232 , solution = &rgf_solution.
234 , tgt_ticket = &tgt_ticket.
235 , outSuccess = httpSuccess
236 , outResponseStatus = responseStatus
241 set _fin_st_proj_adverse_dtl(obs=1);
242 call symputx("adverse_scenario", scenario_name, "L");
246 %put ERROR: The financial statement projection - adverse results dataset does not exist;
250 %if %rsk_dsexist(_fin_st_proj_base_dtl) and %rsk_dsexist(_fin_st_proj_adverse_dtl) and %rsk_dsexist(RISKAGG_SUMM_ENTITY) %then %do;
252 %irmst_create_capital_adq_summary(fsp_base_ds = _fin_st_proj_base_dtl
253 , fsp_adverse_ds = _fin_st_proj_adverse_dtl
254 , loss_dist_ds = RISKAGG_SUMM_ENTITY
255 , reload_lasr_method = &lasr_load_method.
256 , config_set = &config_set_id.
257 , tgt_ticket = &tgt_ticket.
258 , scenario_nm = %str(&base_scenario. - &adverse_scenario.)
259 , analysis_run_nm = &analysis_run_name.
260 , cycle_nm = &cycle_name.
261 , outVarStatus = status
264 %if %rsk_dsexist(RISKAGG_SUMM_ENTITY) and (&status. = Successful) %then %do;
266 %irmc_refresh_lasr_schema_view(lasr_lib = &lasr_libref.
267 , mart_table_name = &solutionId._CAPITAL_ADEQUACY_SUMMARY
268 , rls_table_name = &solutionId._CAPITAL_ADEQUACY_SUMMARY_RLS
269 , meta_repository = &meta_repository.
270 , lasr_library_name = &lasr_library_name.
271 , lasr_meta_folder = &lasr_meta_folder.
280%irmc_update_ctrl_table(cycle_id = &cycle_key.
281 , analysis_run_id = &analysis_run_key.
282 , dr_libref = &dr_libref.
284 , entry_id = &analysis_run_key.
285 , entry_name = Risk Aggregation
286 , entry_location = analysisRuns