4%macro irmst_enrich_portfolio(ds_in_portfolio =
8 , ds_in_map_geo_hierarchy =
9 , ds_in_map_product_hierarchy =
10 , ds_in_map_reg_product_hierarchy =
11 , ds_in_map_lob_hierarchy =
12 , ds_in_map_dpd_type =
13 , ds_in_map_ltv_type =
15 , enrich_counterparty_flg = N
23 %let ptf_table = &ds_in_portfolio.;
25 %
if (%sysevalf(%superq(enrich_counterparty_flg) =,
boolean)) %then
26 %let enrich_counterparty_flg = Y;
28 %let enrich_counterparty_flg = %upcase(&enrich_counterparty_flg.);
31 %
if (%sysevalf(%superq(enrich_sppi_flg) =,
boolean)) %then
32 %let enrich_sppi_flg = Y;
34 %let enrich_sppi_flg = %upcase(&enrich_sppi_flg.);
37 %
if(&enrich_counterparty_flg. = Y and &enrich_sppi_flg. = Y) %then %
do;
39 %let ptf_table = _tmp_portfolio_cpty_sppi;
40 data _tmp_portfolio_cpty_sppi;
49 %
else %
if(&enrich_counterparty_flg. = N and &enrich_sppi_flg. = Y) %then %
do;
51 %let ptf_table = _tmp_portfolio_sppi;
52 data _tmp_portfolio_sppi;
60 %
else %
if(&enrich_counterparty_flg. = Y and &enrich_sppi_flg. = N) %then %
do;
62 %let ptf_table = _tmp_portfolio_cpty;
63 data _tmp_portfolio_cpty;
73 data &ds_out. / view = &ds_out.;
77 %irm_get_attrib_def(ds_in = &ptf_table.)
78 %irm_get_attrib_def(ds_in = &ds_in_map_geo_hierarchy., drop_vars = geography_cd)
79 %irm_get_attrib_def(ds_in = &ds_in_map_product_hierarchy., drop_vars = product_cd)
80 %
if (%sysevalf(%superq(ds_in_map_reg_product_hierarchy) ne,
boolean)) %then
82 %irm_get_attrib_def(ds_in = &ds_in_map_reg_product_hierarchy., drop_vars = product_cd)
84 %irm_get_attrib_def(ds_in = &ds_in_map_lob_hierarchy., drop_vars = lob_id)
85 %irm_get_attrib_def(ds_in = &ds_in_map_dpd_type., drop_vars = dpd_start dpd_end)
86 %irm_get_attrib_def(ds_in = &ds_in_map_ltv_type., drop_vars = ltv_start ltv_end)
87 ORIG_CREDIT_STATE length = 8. label =
"Credit State at origination"
88 CREDIT_STATE length = 8. label =
"Current Credit State"
89 ORIG_STD_RATING_GRADE length = $32. label =
'Standardized Rating Grade at Origination'
90 STD_RATING_GRADE length = $32. label =
'Standardized Rating Grade'
91 DMA_EXPANSION_FLAG length = $1. label =
'DMA Expansion Flag'
92 TO_RISK_RATING length = $8. label =
'Market Risk Rating'
93 EXPOSURE_DELTA_MULTIPLIER length = 8. label =
'Exposure Delta Multiplier'
110 set &ds_in_portfolio.;
113 EXPOSURE_DELTA_MULTIPLIER=0;
121 __rx__ = prxparse(
"/^\d\s/");
124 declare hash hEntity(dataset:
"&ds_in_entity.");
125 hEntity.defineKey(
"reporting_dt",
"entity_id");
126 hEntity.defineData(
"entity_id");
127 hEntity.defineDone();
130 declare hash hGeo(dataset:
"&ds_in_map_geo_hierarchy.");
131 hGeo.defineKey(
"geography_cd");
132 hGeo.defineData(all:
"yes");
136 declare hash hProduct(dataset:
"&ds_in_map_product_hierarchy.");
137 hProduct.defineKey(
"product_cd");
138 hProduct.defineData(all:
"yes");
139 hProduct.defineDone();
141 %
if (%sysevalf(%superq(ds_in_map_reg_product_hierarchy) ne,
boolean)) %then
144 declare hash hRegProduct(dataset:
"&ds_in_map_reg_product_hierarchy.");
145 hRegProduct.defineKey(
"product_cd");
146 hRegProduct.defineData(all:
"yes");
147 hRegProduct.defineDone();
151 declare hash hLob(dataset:
"&ds_in_map_lob_hierarchy.");
152 hLob.defineKey(
"lob_id");
153 hLob.defineData(all:
"yes");
157 declare hash hDPD(dataset:
"&ds_in_map_dpd_type.");
158 hDPD.defineKey(
"dpd_start");
159 hDPD.defineData(
"dpd_class",
"dpd_start",
"dpd_end");
160 declare hiter hiterDPD(
"hDPD");
164 declare hash hLTV(dataset:
"&ds_in_map_ltv_type.");
165 hLTV.defineKey(
"ltv_start");
166 hLTV.defineData(
"ltv_desc",
"ltv_start",
"ltv_end");
167 declare hiter hiterLTV(
"hLTV");
170 %
if(&enrich_counterparty_flg. = Y) %then %
do;
172 declare hash hCpty(dataset:
"&ds_in_counterparty.");
173 hCpty.defineKey(
"reporting_dt",
"counterpartyid");
174 hCpty.defineData(all:
"yes");
179 %
if(&enrich_sppi_flg. = Y) %then %
do;
181 declare hash hSppi(dataset:
"&ds_in_sppi.");
182 hSppi.defineKey(
"reporting_dt",
"instid",
"entity_id");
183 hSppi.defineData(all:
"yes");
190 if(hEntity.check() = 0) then
do;
192 call missing(of geography_lev:, of product_lev:, of lob_lev:, dpd_class, ltv_desc);
193 __rch__ = hGeo.find();
194 __rch__ = hProduct.find();
195 %
if (%sysevalf(%superq(ds_in_map_reg_product_hierarchy) ne,
boolean)) %then
197 __rch__ = hRegProduct.find();
199 __rch__ = hLob.find();
202 __rch__ = hiterDPD.first();
203 do while (__rch__ = 0);
204 if dpd_start <= days_past_due_cnt <= dpd_end then leave;
205 __rch__ = hiterDPD.next();
209 __rch__ = hiterLTV.first();
210 do while (__rch__ = 0);
211 if ltv_start <= ltv_rt <= ltv_end then leave;
212 __rch__ = hiterLTV.next();
215 %
if(&enrich_counterparty_flg. = Y) %then %
do;
217 if(hCpty.check() = 0) then
do;
219 %let ctpy_vars = %rsk_getvarlist(&ds_in_counterparty., pattern =^(?!\b(REPORTING_DT|COUNTERPARTYID)\b));
220 call missing(%sysfunc(prxchange(s/\s+/%str(,) /i, -1, &ctpy_vars.)));
221 __rch__ = hCpty.find();
225 %
if(&enrich_sppi_flg. = Y) %then %
do;
227 if(hSppi.check() = 0) then
do;
229 %let sppi_vars = %rsk_getvarlist(&ds_in_sppi., pattern =^(?!\b(REPORTING_DT|INSTID|ENTITY_ID)\b));
230 call missing(%sysfunc(prxchange(s/\s+/%str(,) /i, -1, &sppi_vars.)));
231 __rch__ = hSppi.find();
236 if(prxmatch(__rx__, ORIG_STD_RATING_GRADE)) then
237 ORIG_CREDIT_STATE = input(scan(ORIG_STD_RATING_GRADE, 1,
" "), 8.);
238 if(prxmatch(__rx__, STD_RATING_GRADE)) then
239 CREDIT_STATE = input(scan(STD_RATING_GRADE, 1,
" "), 8.);