28%let sas_risk_workgroup_dir = ${globals.sas_risk_workgroup_dir};
31%let cycle_key = ${context.cycle.key};
34%let analysis_run_key = ${context.analysisRun.key};
37%let current_dt_ymd = %sysfunc(date(), yymmddd10.);
38%let current_tm_tod = %sysfunc(time(), tod10.);
40%let custom_AnalysisName =${params.ANALYSISDATANAME};
44%let ValueAtRisk_Level = ${params.VARLEVEL};
47%let rescaleInterval_count = ${params.RESCALEINTERVALCOUNT};
50%include
"&sas_risk_workgroup_dir./groups/Public/SASRiskManagementCore/cycles/&cycle_key./init.sas" / lrecl = 32000 source2;
56%irm_rest_get_rgf_cycle(key = &cycle_key.
57 , host = &rgf_protocol:
59 , tgt_ticket = &tgt_ticket.
61 , outVarTicket = ticket
62 , outSuccess = httpSuccess
63 , outResponseStatus = responseStatus
67 call symputx(
"cycle_baseDt", baseDt,
"L");
68 call symputx(
"cycle_entityId", entityId,
"L");
72data &ds_out_model_result.;
73set &ds_in_model_result.(
76 ContributionVaR=Component_ValueAtRisk
78 Alpha=ValueAtRisk_Alpha
80 ContributionES=Component_ExpectedShortfall
82 ASSET_TYPE=ASSET_TYPE_DESC
86 if simulationPart eq
"P/L" then simulationPart=
"Profit and Loss";
87 else if simulationPart eq
"_ACCINT_" then simulationPart=
"Accrued Interest";
88 else if simulationPart eq
"_DUR_" then simulationPart=
"Duration";
89 else if simulationPart eq
"_YIELD_" then simulationPart=
"Yield";
90 else if simulationPart eq
"_SWAP_DUR_" then simulationPart=
"Swap Duration";
91 else if simulationPart eq
"_VALUE_ORIG_CURRENCY_" then simulationPart=
"Value";
92 else if simulationPart eq
"_DUR_CCY1_LEG_" then simulationPart=
"CCY 1 Leg Duration";
93 else if simulationPart eq
"_DUR_CCY2_LEG_" then simulationPart=
"CCY 2 Leg Duration";
94 else if simulationPart eq
"_DUR_FIX_LEG_" then simulationPart=
"Fix Leg Duration";
95 else if simulationPart eq
"_DUR_FLOAT_LEG_" then simulationPart=
"Float Leg Duration";
102 EXPECTEDLOSS =-EXPECTEDLOSS*&rescaleInterval_count.;
103 ValueAtRisk =EXPECTEDLOSS+(ValueAtRisk-EXPECTEDLOSS/&rescaleInterval_count.)*sqrt(&rescaleInterval_count.);
104 Component_ValueAtRisk =EXPECTEDLOSS+(Component_ValueAtRisk-EXPECTEDLOSS/&rescaleInterval_count.)*sqrt(&rescaleInterval_count.);
105 Economic_Capital =ValueAtRisk;
106 Component_Economic_Capital =Component_ValueAtRisk;
107 ExpectedShortfall =ExpectedShortfall *&rescaleInterval_count.;
108 Component_ExpectedShortfall =Component_ExpectedShortfall *&rescaleInterval_count.;
109 ValueAtRisk_Alpha=&ValueAtRisk_Level.;
113%macro custom_process_bep;
115 %let ds_in_bep_x_model = st_stg.bep_x_model;
116 %let ds_in_bep_details = st_stg.bep_details;
118 %let TotRows = %rsk_attrn(&ds_in_bep_x_model., nobs);
119 %let toRow = &TotRows.;
120 %let TotRuns = &toRow.;
125 set &ds_in_bep_x_model.(firstobs = &fromRow. obs = &toRow.);
127 call symputx(cats(
"bep_key_", put(_N_, 8.)), bepKey,
"L");
128 call symputx(cats(
"planDataCount_", put(_N_, 8.)), planDataCount,
"L");
129 call symputx(cats(
"bep_name_", put(_N_, 8.)), bepName,
"L");
130 call symputx(cats(
"segmentation_vars_", put(_N_, 8.)), segmentationVarList,
"L");
131 call symputx(cats(
"allocation_flg_", put(_N_, 8.)), allocationFlg,
"L");
132 call symputx(cats(
"interval_", put(_N_, 8.)), interval,
"L");
133 call symputx(cats(
"interval_count_", put(_N_, 8.)), intervalCount,
"L");
134 call symputx(cats(
"target_var_", put(_N_, 8.)), targetVariable,
"L");
135 call symputx(cats(
"model_key_", put(_N_, 8.)), modelKey,
"L");
136 call symputx(cats(
"model_run_key_", put(_N_, 8.)), modelRunKey,
"L");
137 call symputx(cats(
"planning_data_key_", put(_N_, 8.)), planningDataKey,
"L");
138 call symputx(cats(
"alloc_scheme_key_", put(_N_, 8.)), allocationSchemekey,
"L");
139 call symputx(cats(
"planDataCount", put(_N_, 8.)), planDataCount,
"L");
144 %
if %sysevalf(%superq(tgt_ticket) =,
boolean) %then %
do;
145 %irm_rest_get_ticket(url = &rgf_protocol.:
146 , username = &_i_run_rm_user_id.
147 , password = &_i_run_rm_user_password.
149 , outVarTicket = tgt_ticket
154 proc datasets library = work nolist nodetails nowarn;
155 delete planning_data_:;
159 %
do _i_run_ = 1 %to &TotRuns.;
164 %let segmentation_vars = &&segmentation_vars_&_i_run_..;
165 %let ds_in_bep_expectations = bep_expectations_&_i_run_.;
166 %let ds_in_bep_planning_data = planning_data_&&planning_data_key_&_i_run_..;
167 %let bep_target_var = &&target_var_&_i_run_..;
172 %
if &&allocation_flg_&_i_run_.. = Y %then %
do;
174 data bep_expectations_&_i_run_.;
175 set &ds_in_bep_details.(where = (bepKey = &&bep_key_&_i_run_..));
178 targetVarName ActivationHorizon
179 &&segmentation_vars_&_i_run_..
180 interval changeType modelKey
181 absoluteValue relativeValue relativePct
188 %
if(not %rsk_dsexist(planning_data_&&planning_data_key_&_i_run_..)) %then %
do;
189 %let httpSuccess = 0;
190 %let responseStatus =;
191 %irm_rgf_retrieve_analysis_data(key = &&planning_data_key_&_i_run_..
193 , outds = planning_data_&&planning_data_key_&_i_run_..
194 , outds_partition_list = partition_list_&_i_run_.
196 , outds_dataInfo = planning_dataInfo_&_i_run_.
197 , outds_dataDef = planning_dataDef_&_i_run_.
198 , host = &rgf_protocol.:
199 , server = &rgf_service.
200 , solution = &rgf_solution.
202 , tgt_ticket = &tgt_ticket.
203 , outVarTicket = ticket
204 , outSuccess = httpSuccess
205 , outResponseStatus = responseStatus
211 %
if(not &httpSuccess. or not %rsk_dsexist(planning_data_&&planning_data_key_&_i_run_..)) %then
217 %
if(%sysfunc(prxmatch(/^(\d+)$/, &&model_run_key_&_i_run_..))) %then %
do;
222 %let httpSuccess = 0;
223 %let responseStatus =;
224 %irm_rest_get_rgf_model_run(host = &rgf_protocol.:
225 , server = &rgf_service.
226 , solution = &rgf_solution.
228 , tgt_ticket = &tgt_ticket.
229 , key = &&model_run_key_&_i_run_..
230 , outds = model_run_&_i_run_.
231 , outds_params = model_run_params_&_i_run_.
232 , fout_code = fcd_&_i_run_.
233 , outVarTicket = ticket
234 , outSuccess = httpSuccess
235 , outResponseStatus = responseStatus
241 %
if(not &httpSuccess. or not %rsk_dsexist(model_run_&_i_run_.)) %then
249 %macro stm_allocate(gen_type =);
250 %put ERROR: The allocation model associated to the Business Evolution Plan &&bep_name_&_i_run_.. (key: &&bep_key_&_i_run_..) does not implement the macro STM_ALLOCATE;
254 %include fcd_&_i_run_. /source2 lrecl = 32000;
259 %let post_run_flag=TRUE;
262 %stm_allocate(gen_type =);
270 %put ERROR: An allocation scheme is needed;