32%macro irmst_market_agg_bep_analysis( ds_in_portfolio =
47 %put NOTE: The market risk analysis will be stressed at the aggregate level.;
49 %
if %UPCASE(&target_var.) NE EXPOSURE_DELTA_MULTIPLIER %then %do;
50 %put ERROR: the model defined in irmst_market_agg_bep_analysis.sas requires the BEP to be defined on the variable EXPOSURE_DELTA_MULTIPLIER.;
55 %if (%sysevalf(%superq(by_vars) ne,
boolean)) %then %do;
63 %if (%sysevalf(%superq(scenario_var) ne,
boolean)) %then %do;
64 %let scenario_flg = Y;
67 %let scenario_flg = N;
71 %let unquoted_csv_byvar_list = %sysfunc(prxchange(s/\s+/%str(, )/i, -1, &by_vars.));
73 %let quoted_csv_byvar_list = %sysfunc(prxchange(s/(\w+)/"$1"/i, -1, %bquote(&unquoted_csv_byvar_list.)));
76 proc sort data = &ds_in_projection
77 out = _tmp_analysis_proj_srt_;
78 by &by_vars. &scenario_var. &horizon_var.;
82 %if (&scenario_flg. = N) %then %do;
83 %let scenario_var=_tmp_scenario_var_;
84 data _tmp_analysis_proj_srt_;
85 length &scenario_var. $32.;
86 set _tmp_analysis_proj_srt_;
87 &scenario_var.="_tmp_scenario_name_";
92 proc sort data=&ds_in_portfolio.
93 out=_tmp_analysis_ds_in_;
94 by &by_vars. &scenario_var. forecast_time;
99 select count(*) into: proj_cnt
100 from _tmp_analysis_proj_srt_;
103 %if &proj_cnt.<1 %then %do;
104 %put ERROR: Not enough valid projections: skip the market risk stress analysis.;
109 set _tmp_analysis_ds_in_;
110 length changeType $10.;
111 by &by_vars. forecast_time;
113 declare hash h(dataset: "_tmp_analysis_proj_srt_(rename=(&horizon_var.=forecast_time)");
114 h.definedata("&absoluteValue_var.","changeType");
115 h.definekey("ed_csv_byvar_list.,"forecast_time");
118 call missing(&absoluteValue_var.);
121 if changeType="abs_add" then do;
122 if absoluteValue ne 0 and forecast_time=0 then do;
123 put "ERROR: EXPOSURE_DELTA_MULTIPLIER must be 0 in the market Business Evolution Plan for forecast time 0 if change type is 'Absolute'";
127 bep_factor=(1+COALESCE(&absoluteValue_var.,0));
130 if changeType="rel_add" then do;
131 if absoluteValue ne 1 and forecast_time=0 then do;
132 put "ERROR: EXPOSURE_DELTA_MULTIPLIER must be 1 in the market Business Evolution Plan for forecast time 0 if change type is 'Relative'";
136 bep_factor=COALESCE(&absoluteValue_var.,0);
139 ValueAtRisk =ValueAtRisk *bep_factor;
140 Component_ValueAtRisk =Component_ValueAtRisk *bep_factor;
141 ExpectedShortfall =ExpectedShortfall *bep_factor;
142 Component_ExpectedShortfall =Component_ExpectedShortfall*bep_factor;
143 Economic_Capital =Economic_Capital *bep_factor;
144 Component_Economic_Capital =Component_Economic_Capital *bep_factor;
145 EXPECTEDLOSS =EXPECTEDLOSS *bep_factor;
146 drop rc changeType bep_factor;
150 %if %upcase(&debug.) ne TRUE %then %do;
151 proc datasets library = work nolist nodetails;
153 _tmp_analysis_proj_srt_