SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_run_atm_overlay.sas
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 SAS Institute Inc. Cary, NC, USA
3*/
4
5/**
6 \file
7 \anchor irmst_run_atm_overlay.sas
8
9 \brief irmst_run_atm_overlay joins the user specified ATM with the existing transition matrix and stores it as analysis data.
10
11 \param [in] in_model_tm_results Transition matrix analysis data
12 \param [in] in_atm_upload The ATM uploaded by the user and processed in irmst_import_atm_spreadsheet
13 \param [in] scenario_to_overlay Comma-delimited list of scenario names
14 \param [in] analysis_data_name Name of resulting analysis data
15 \param [in] analysis_data_desc Description of resulting analysis data
16 \param [in] analysis_run_id ID of the analysis run this macro is being run in
17 \param [in] base_dt The parent cycles base date
18 \param [in] cycle_id The parent cycles ID
19 \param [in] status_cd Status of the resulting analysis data
20 \param [in] visibility_cd Visibility of the resulting analysis data
21 \param [in] libref Libref of the resulting analysis data
22 \param [in] schema_name Analysis data schema name (taken from existing transition matrix)
23 \param [in] schema_version Analysis data schema version (taken from existing transition matrix)
24 \param [in] entity_id Entity ID of the parent cycle
25 \param [in] host Host name the run is being executed for
26 \param [in] server Server the run is being executed in
27 \param [in] solution Solution the run is being executed in
28 \param [in] port Port to connect over
29 \param [in] tgt_ticket Authentication for requests
30 \param [in] debug Determines if the macro is run in debug mode
31 \param [out] out_atm_results_key_var Key of the resulting analysis data (the output transition matrix)
32 \param [out] out_exceptions Table with any exceptions during analysis data storage
33 \param [out] out_analysis_data The output transition matrix
34 \param [out] out_partition_list List of partitions for the analysis data
35 \param [out] out_link_instance Analysis data linked instances
36
37 \author SAS Institute Inc.
38 \date 2021
39*/
40
41%macro irmst_run_atm_overlay(in_model_tm_results =
42 , in_atm_upload =
43 , scenario_to_overlay =
44 , analysis_data_name =
45 , analysis_data_desc =
46 , analysis_run_id =
47 , base_date =
48 , cycle_id =
49 , status_cd =
50 , visibility_cd =
51 , libref = RQSST
52 , schema_name =
53 , schema_version =
54 , entity_id =
55 , out_atm_results_key_var = atm_results_key
56 , out_exceptions = work._atm_upload_exceptions
57 , out_analysis_data = work._atm_upload_analysis_data
58 , out_partition_list = work._atm_upload_partition_list
59 , out_data_definition = work._atm_upload_data_definition
60 , out_link_instance = work._atm_upload_link_instance
61 , host =
62 , server =
63 , solution =
64 , port =
65 , tgt_ticket =
66 , debug =
67 ) / minoperator;
68
69 %local _debug_
70 scen_i
71 scen_nm
72 scenario_to_overlay_quoted;
73
74 /*-----------------------
75 * Align debug parameter
76 *-----------------------*/
77 %if %qupcase(&debug) in (Y YES 1 TRUE) %then
78 %let _debug_ = YES;
79 %else
80 %let _debug_ = NO;
81
82 /*--------------------------------------------------------------------------------------------
83 * Convert comma-delimited list of scenario names into space-delimited list of scenario SK(s)
84 *--------------------------------------------------------------------------------------------*/
85 %do scen_i=1 %to %sysfunc(countw(%superq(scenario_to_overlay), %str(,)));
86 %let scen_nm = %upcase(%scan(%superq(scenario_to_overlay), &scen_i., %str(,)));
87
88 %let scenario_to_overlay_quoted = &scenario_to_overlay_quoted. "&scen_nm.";
89 %end;
90
91 /*--------------
92 * Sanity check
93 *--------------*/
94 %if %sysevalf(%superq(scenario_to_overlay_quoted) ne, boolean) and
95 %sysevalf(%superq(in_atm_upload) eq, boolean) %then
96 %do;
97 %put WARNING: ATM upload is not specified.;
98 %return;
99 %end;
100 %if %sysevalf(%superq(scenario_to_overlay_quoted) eq, boolean) and
101 %sysevalf(%superq(in_atm_upload) ne, boolean) %then
102 %do;
103 %put WARNING: No scenario(s) are specified to perform ATM overlay.;
104 %return;
105 %end;
106
107 /*-----------------------------------------------------------------------------
108 * When both scenario_sk(s) to overlay and ATM analysis data key are specified
109 *-----------------------------------------------------------------------------*/
110 %if %sysevalf(%superq(scenario_to_overlay_quoted) ne, boolean) and
111 %sysevalf(%superq(in_atm_upload) ne, boolean) %then
112 %do;
113 /*---------------------------------------------------------------------
114 * Overlay uploaded ATM data set onto TM data set based on scenario_sk
115 *---------------------------------------------------------------------*/
116 proc sql;
117 create table work.tm_results_w_overlay as
118 select tm.modeling_system_name label="Modeling System Name",
119 tm.modeling_system_version label="Modeling System Version",
120 tm.model_group_name label="Modeling System Group name",
121 tm.business_evolution_plan_name label="Business Evolution Plan Name",
122 tm.master_risk_scenario_name label="Master Risk Scenario Name",
123 tm.mip_scenario_name label="MIP Scenario Name",
124 tm.insttype,
125 tm.scenario_date,
126 tm.from_risk_rating label="From Risk Rating",
127 tm.to_risk_rating label="Migrated Risk Rating",
128 coalesce(atm.migrate_prob, tm.transition_probabilities) as transition_probabilities label="Transition Probabilities",
129 tm.order_num label="Order Number"
130 from &in_model_tm_results. as tm
131 left join
132 &in_atm_upload as atm
133 on upcase(tm.model_group_name) eq upcase(atm.model_group_name) and
134 intnx("month", tm.scenario_date, 0, 'e') eq intnx("month", atm.scenario_date, 0, 'e') and
135 upcase(tm.from_risk_rating) eq upcase(atm.from_rating) and
136 upcase(tm.to_risk_rating) eq upcase(atm.to_rating) and
137 upcase(catx(' - ',tm.business_evolution_plan_name,tm.master_risk_scenario_name)) in (&scenario_to_overlay_quoted)
138 order by tm.order_num;
139 quit;
140
141 /*-------------------------------------------
142 * Upload TM with overlay to RGF
143 *-------------------------------------------*/
144 %let httpSuccess = 0;
145 %let responseStatus = ;
146 %let ticket_tm_upload = ;
147
148 %irm_rgf_store_analysis_data(ds_in = work.tm_results_w_overlay
149 , analysis_data_name = %superq(analysis_data_name)
150 , analysis_data_desc = %superq(analysis_data_desc)
151 , base_date = &base_date.
152 , cycle_id = &cycle_id.
153 , status_cd = &status_cd.
154 , visibility_cd = &visibility_cd
155 , analysis_run_id = &analysis_run_id.
156 , data_definition_name = %superq(analysis_data_name)
157 , data_definition_desc = %superq(analysis_data_desc)
158 , libref = &libref.
159 , schema_name = &schema_name.
160 , schema_version = &schema_version.
161 , entity_id = &entity_id.
162 , out_exceptions = &out_exceptions.
163 , out_analysis_data = &out_analysis_data.
164 , out_partition_list = &out_partition_list.
165 , out_data_definition = &out_data_definition.
166 , out_link_instance = &out_link_instance.
167 , host = &host.
168 , server = &server.
169 , solution = &solution.
170 , port = &port.
171 , tgt_ticket = %superq(rgf_tgt_ticket)
172 , outVarTicket = ticket_upload
173 , outSuccess = httpSuccess
174 , outResponseStatus = responseStatus
175 );
176
177 data _null_;
178 set &out_analysis_data.;
179 call symputx("&out_atm_results_key_var",key, 'g');
180 run;
181
182 /*----------------------------------------------
183 * If debug set to NO, drop intermediate tables
184 *----------------------------------------------*/
185 %if %qupcase(&_debug_.) eq NO %then
186 %do;
187 proc sql;
188 drop table work.in_model_tm_results,
189 work._atm_upload_partition_list,
190 work._atm_upload_exceptions,
191 work._atm_upload_analysis_data,
192 work._atm_upload_partition_list,
193 work._atm_upload_data_definition,
194 work._atm_upload_link_instance
195 ;
196 quit;
197 %end;
198 %end;
199%mend irmst_run_atm_overlay;