SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmc_mip_cm_eba2020_gen.sas
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 SAS Institute Inc. Cary, NC, USA
3 */
4
5/**
6 \file
7 \anchor irm_mip_cm_eba2020_gen_key
8
9 \brief It generates MIP computed methods for the EBA2020 analysis
10
11
12 \param[in] model_run_key The model run key is used for auditing purposes: It is attached to the name of the computed method.
13 \param[in] base_dt The base date is used for auditing purposes: It is attached to the name of the computed method.
14 \param[in] mipHorizon It determines how many computed method should be generated.
15 \param[in] computedmethod_name_prefix It is the prefix used in the computed method name.
16 \param[in] adverse_scenario_name It is the name of the adverse scenario used in the computed method.
17 \param[in] basecase_scenario_name It is the name of the basecase scenario used in the computed method.
18 \param[out] ds_out_cm_list It is the name of the table containing the names of the computed method that have been created.
19 \param[in] mip_cm_eba2020_template It is the name of the template to be used for the generation of the computed method.
20
21
22
23
24
25 \ingroup DynamicPortfolio
26
27 \author SAS Institute INC.
28 \date 2018
29
30*/
31
32%macro irmc_mip_cm_eba2020_gen( model_run_key =
33 , base_dt =
34 , mipHorizon =
35 , computedmethod_name_prefix =
36 , adverse_scenario_name =
37 , basecase_scenario_name =
38 , ds_out_cm_list =
39 , mip_cm_eba2020_template =
40 );
41
42
43 /* Reset the ticket macro variable in case the ticket exists and was previously used for an RGF call */
44 %let ticket=;
45
46 /* It retrieves the maximum forecast time and the BEP short name.
47 Notice that this will work under the assumption that there is only BEP and only two MRSs: one for base case and one for adverse.
48 Also, the FTs across the two different MRSs need to be common. If this assumption does not hold, then you may have to change the following code.*/
49 data _null_;
50 set ST_STG.SCENARIO_INFO end=last;
51 retain max_forecasttime 0;
52 max_forecasttime=max(forecastTime,max_forecasttime);
53 if last then do;
54 call symputX('bep_ShortName',bepShortName);
55 call symputX('ft_max',max_forecasttime);
56 end;
57 run;
58
59
60 /* It retrieves the number of horizons */
61 %if(%upcase(&mipHorizon.)=MAX or %sysevalf(%superq(mipHorizon) =, boolean)) %then %do;
62 data _null_;
63 set ST_STG.SCENARIO_DATA end=last;
64 retain max_horizon 0;
65 max_horizon=max(HORIZON,max_horizon);
66 if last then do;
67 call symputX('cnt_horizon',max_horizon);
68 end;
69 run;
70 %end;
71 %else %do;
72 %let cnt_horizon=&mipHorizon.;
73 %end;
74
75 /* It retrieves the base date. */
76 %let base_dt_ymdn = %sysfunc(putn(&base_dt., yymmddn8.));
77
78 /* It creates ft_max computed methods. */
79 %do i_ft=0 %to &ft_max.;
80
81 /* It creates the name of the computed method. */
82 %let cm_name=&computedmethod_name_prefix.&i_ft._&base_dt_ymdn._&model_run_key.;
83
84 /* It creates the beginning part of the computed method. */
85 filename body temp;
86 data _null_;
87 file body;
88 put '/*Begin: Dynamically assign the values of the following variables.*/';
89 put '%let period_cnt =' "&cnt_horizon.;";
90 put '%let ft =' "&i_ft.;";
91 put '%let Scenario_base =' "&bep_ShortName._&basecase_scenario_name._FT&i_ft.;";
92 put '%let Scenario_adv =' "&bep_ShortName._&adverse_scenario_name._FT&i_ft.;";
93 put '%let computedmethod_name =' "&cm_name.;";
94 put '/*End: Dynamically assign the values of the following variables.*/';
95 put ' ';
96 run;
97
98 /*It adds the names of the computed methods to the output data set.*/
99 %if &i_ft.=0 %then %do;
100 data &ds_out_cm_list.;
101 length computedmethod $500.;
102 computedmethod="&cm_name.";
103 run;
104 %end;
105 %else %if &i_ft.>0 %then %do;
106 data &ds_out_cm_list.;
107 set &ds_out_cm_list. end=last;
108 output;
109 if last then do;
110 computedmethod="&cm_name.";
111 output;
112 end;
113 run;
114 %end;
115
116 /*It adds the template of the computed method to the actual computed method.*/
117 data _null_;
118 file body mod;
119 infile "&mip_cm_eba2020_template." lrecl = 32000;
120 input;
121 put _infile_;
122 run;
123
124 /*It packages the computed method for MIP*/
125 %let httpSuccess = 0;
126 %let responseStatus =;
127 %irm_rest_create_mip_exec_pgm(host = &mip_protocol.://&mip_host.
128 , server = &mip_service.
129 , port = &mip_port.
130 , tgt_ticket = &tgt_ticket.
131 , workgroup = &mip_ms_workgroup.
132 , name = &cm_name.
133 , description = Computed Method for modeling system &mip_ms_name. (&mip_ms_version.). RGF modelRunkey: &model_run_key.
134 , type = computed
135 , rollup= TRUE
136 , code = body
137 , outds = mip_pre_pgm_detail
138 , outVarTicket = ticket
139 , outSuccess = httpSuccess
140 , outResponseStatus = responseStatus
141 , restartLUA = Y
142 , clearCache = Y
143 );
144
145 %end;
146
147%mend;
148
149