SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_script_control_model.sas
1/* *************************************************** */
2/* Control Model Script: Input Parameters */
3/* *************************************************** */
4
5/* TGT Authentication Ticket */
6%let rgf_tgt_ticket = ${globals.ticket};
7
8/* Get the root location of the SAS Risk Workgroup Application */
9%let sas_risk_workgroup_dir = ${globals.sas_risk_workgroup_dir};
10
11/* RGF User Id */
12%let rgf_user_id = ${globals.rgfUserId};
13
14/* Cycle Id */
15%let cycle_id = ${context.cycle.key};
16
17/* Analysis Run Id and name */
18%let analysis_run_id = ${context.analysisRun.key};
19%let analysis_run_name = ${context.analysisRun.name};
20
21/* Model Run Id and name */
22%let model_run_id = ${context.modelRun.key};
23%let model_run_name = ${context.modelRun.name};
24
25/* Control Model Run Key */
26%let control_model_run_id = ${context.controlModelRun.key};
27
28/* Control Framework Key */
29%let control_framework_key = ${context.cycle.nav("cycle_controlFramework|RMC")[0].key};
30
31/* Model Id from analysis run */
32%let model_id_ar = ${context.analysisRun.nav("analysisRun_model|RMC")[0].custObj1Id};
33
34/* Model Id from model run */
35%let model_id_mr = ${context.modelRun.nav("model_modelRun|RMC")[0].custObj1Id};
36
37/* Model Name from analysis run */
38%let model_name_ar = ${context.analysisRun.nav("analysisRun_model|RMC")[0].custObjNm};
39
40/* Model Name from model run */
41%let model_name_mr = ${context.modelRun.nav("model_modelRun|RMC")[0].custObjNm};
42
43/* ********************************************* */
44
45/* Initialize the environment */
46%include "&sas_risk_workgroup_dir./groups/Public/SASRiskManagementCore/cycles/&cycle_id./init.sas" / lrecl = 32000 source2;
47
48/* Now add the script own parameters */
49
50/* Flag for whether passed controls should be logged */
51%let log_passes_flag = ${params.LOGSUCCESSESFLG};
52
53/* LASR load method (Append/Replace/Do Not Load) */
54%let lasr_load_method = ${params.LASRLOADMETHOD};
55
56/* Key of the previous period cycle */
57%let prev_cycle_key = ${params.PREVPERIODCYCLE.key};
58
59/* IRM Configuration Set Id */
60%let config_set_id = ${params.CONFIGSETID};
61
62/* Maximum wait time for IRM job completion: <number of seconds> */
63%let max_wait = ${params.MAXWAIT};
64
65/* Log Level: 1-4 */
66%let log_level = ${params.LOGLEVEL};
67
68/* RMC parameters */
69%let solutionLibrefPrefix = RMC;
70
71/* If the control results need to be written to a details_app folder other than the default SASRiskManagementCore, then specify the name of the folder here */
72%let result_details_app =;
73
74/* Set logging options (based on the value of LOG_LEVEL macro variable) */
75%irm_set_logging_options();
76
77/* Process LASR load method */
78%let reload_lasr_flg = %irmc_process_lasr_load_method(&lasr_load_method.);
79
80/* Store the model key - either from the analysis run (if exists) or from the model run */
81%let model_id = &model_id_ar.;
82%if(%sysevalf(%superq(model_id_ar) eq, boolean)) %then %do;
83 %let model_id = &model_id_mr.;
84%end;
85
86/* Store the run name - either from the analysis run (if exists) or from the model run */
87%let run_name = &analysis_run_name.;
88%if(%sysevalf(%superq(run_name) eq, boolean)) %then %do;
89 %let run_name = &model_run_name.;
90%end;
91
92/* Store the model name - either from the analysis run (if exists) or from the model run */
93%let model_name = &model_name_ar.;
94%if(%sysevalf(%superq(model_name_ar) eq, boolean)) %then %do;
95 %let model_name = &model_name_mr.;
96%end;
97
98/* Generate the where clause for subsetting the cycle control table by run id */
99%let run_id_where_clause = analysis_run_id = &analysis_run_id.;
100%if(%sysevalf(%superq(analysis_run_id) eq, boolean)) %then %do;
101 %let run_id_where_clause = model_run_id = &model_run_id.;
102%end;
103
104/* Get any IRM jobflow instances associated with the parent run */
105%let jobflow_instance_keys=;
106%let ctrl_ds_name = cycle_ctrl_&cycle_id.;
107%if(%rsk_dsexist(&dr_libref..&ctrl_ds_name.)) %then %do;
108 proc sql;
109 select entry_id, entry_dttm
110 into : jobflow_instance_keys separated by '|' , : jobflow_entry_dttms separated by '|'
111 from &dr_libref..&ctrl_ds_name.
112 where cycle_id = &cycle_id.
113 and entry_type = "IRM"
114 and (&run_id_where_clause.)
115 order by entry_dttm;
116 quit;
117%end;
118
119/* Set Instance Parameters */
120%let jobflow_category = Controls;
121%let jobflow_type = irmc_control_framework;
122%let instance_date = %sysfunc(date(), yymmddp10.);
123%let instance_time = %sysfunc(prxchange(s/(\d+):(\d+):(\d+)/$1h$2m$3s/i, -1, %sysfunc(time(), tod8.)));
124%let instanceName = Control Framework Execution &instance_date._&instance_time. Cycle &cycle_id.;
125%let instanceDesc = Execute Control Framework Evaluations (&model_name.);
126
127%if(%sysevalf(%superq(workgroup) eq, boolean)) %then %do;
128 %let workgroup=.;
129%end;
130
131%if(%sysevalf(%superq(control_model_run_id) eq, boolean)) %then %do;
132 %let control_model_run_id=.;
133%end;
134
135data work.control_option;
136 length
137 config_name $32.
138 config_value $10000.
139 ;
140 config_name = "WORKGROUP"; config_value = "&workgroup."; output;
141 config_name = "INSTANCEKEYS"; config_value = "&jobflow_instance_keys."; output;
142 config_name = "LOG_PASSES_FLAG"; config_value = "&log_passes_flag."; output;
143 config_name = "CONTROL_FRAMEWORK_KEY"; config_value = "&control_framework_key."; output;
144 config_name = "CONTROL_MODEL_RUN_ID"; config_value = "&control_model_run_id."; output;
145 config_name = "MODEL_ID"; config_value = "&model_id."; output;
146 config_name = "RUN_NAME"; config_value = "&run_name."; output;
147 config_name = "GENERATED_ON"; config_value = put(datetime(), datetime21.); output;
148 config_name = "PERSPECTIVE_CONTENT_VERSION"; config_value = "&content_version."; output;
149 config_name = "PERSPECTIVE_DR_LIBREF"; config_value = "RQSST"; output;
150 config_name = "SOLNID"; config_value = "&perspectiveId."; output;
151 config_name = "PREV_CYCLE_KEY"; config_value = "&prev_cycle_key."; output;
152 %if(%sysevalf(%superq(result_details_app) ne, boolean)) %then %do;
153 config_name = "RESULT_DETAILS_APP"; config_value = "&result_details_app."; output;
154 %end;
155run;
156
157data work.run_option;
158 length
159 config_name $32.
160 config_value $10000.
161 ;
162 config_name = "RMC_FA_ID"; config_value = "&rmc_fa_id."; output;
163 config_name = "CYCLE_ID"; config_value = "&cycle_id."; output;
164 config_name = "ANALYSIS_RUN_ID"; config_value = "&analysis_run_id."; output;
165 config_name = "MODEL_RUN_ID"; config_value = "&model_run_id."; output;
166 config_name = "MAX_WAIT"; config_value = "&max_wait."; output;
167 config_name = "LOG_LEVEL"; config_value = "&log_level."; output;
168 config_name = "RELOAD_LASR_FLG"; config_value = "&reload_lasr_flg."; output;
169 config_name = "RGF_USER_ID"; config_value = "&rgf_user_id."; output;
170 /* Override the Risk Stratum Core values below to store the data in the solution-specific locations */
171 config_name = "DR_LIBRARY_NAME"; config_value = "&dr_library_name."; output;
172 config_name = "MART_LIBRARY_NAME"; config_value = "&mart_library_name."; output;
173 config_name = "LASR_LIBRARY_NAME"; config_value = "&lasr_library_name."; output;
174 config_name = "LASR_META_FOLDER"; config_value = "&lasr_meta_folder."; output;
175run;
176
177%let instanceKey =;
178%let jobflow_status = Unknown;
179/* Create job flow instance and wait for completion */
180%irm_rest_create_jobflow_instance(instance_name = &instanceName.
181 , description = &instanceDesc.
182 , entityId = &entity_id.
183 , entityRoleKey = &entity_role_key.
184 , category = &jobflow_category.
185 , jobflowFile = &jobflow_type.
186 , baseDate = &irm_base_dt.
187 , configSetId = &config_set_id.
188 , federatedAreaID = &rmc_fa_id.
189 , sourceFederatedAreaId = &rmc_fa_id.
190 , src_param_tables = work.run_option work.control_option
191 , tgt_param_tables = &solutionLibrefPrefix._CFG.run_option &solutionLibrefPrefix._CFG.control_option
192 , wait_flg = Y
193 , pollInterval = 3
194 , maxWait = &max_wait.
195 , host = &irm_protocol.://&irm_host.
196 , port = &irm_port.
197 , tgt_ticket = &rgf_tgt_ticket.
198 , outvar = instanceKey
199 , outVarStatus = jobflow_status
200 );
201
202%if(&jobflow_status. = Successful) and %rsk_dsexist(&lasr_libref..&perspectiveId._CNTRL_EXEC_RESULTS) %then %do;
203 /* Refresh the Star Schema View for the Control Execution Results */
204 %irmc_refresh_lasr_schema_view(lasr_lib = &lasr_libref.
205 , mart_table_name = &perspectiveId._CNTRL_EXEC_RESULTS
206 , rls_table_name = &perspectiveId._CNTRL_EXEC_RESULTS_RLS
207 , meta_repository = &meta_repository.
208 , lasr_library_name = &lasr_library_name.
209 , lasr_meta_folder = &lasr_meta_folder.
210 );
211%end;
212%if(&jobflow_status. = Successful) and %rsk_dsexist(&lasr_libref..&perspectiveId._CNTRL_LIMIT_RESULTS) %then %do;
213 /* Refresh the Star Schema View for the Control Limit Results */
214 %irmc_refresh_lasr_schema_view(lasr_lib = &lasr_libref.
215 , mart_table_name = &perspectiveId._CNTRL_LIMIT_RESULTS
216 , rls_table_name = &perspectiveId._CNTRL_LIMIT_RESULTS_RLS
217 , meta_repository = &meta_repository.
218 , lasr_library_name = &lasr_library_name.
219 , lasr_meta_folder = &lasr_meta_folder.
220 );
221%end;
222
223/* Update the Cycle control table */
224%irmc_update_ctrl_table(cycle_id = &cycle_id.
225 , model_run_id = &control_modeL_run_id.
226 , dr_libref = &dr_libref.
227 , entry_type = IRM
228 , entry_id = &instanceKey.
229 , entry_name = &instanceName.
230 );
231