SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
install_post_rgf_server_restart.sas
1/*
2 As the name suggests, this is meant to be run after the install and the dataloader has been submitted by the content deployment tool. It loads data defintions, links
3 data maps to them (data maps were loaded as part of the dataloader) and loads the VA report configuration table
4*/
5options mprint mprintnest symbolgen source2;
6
7/* ------------------------------------------------------------
8 * Defines a standard set of SAS macros for connecting to
9 * RGF and RSM and connects to the metadata server
10 * ------------------------------------------------------------ */
11
12/* Federated Area Id (as specified in SMC) */
13%let irm_fa_id = %sysget(irm_fa_id);
14
15/* Configuration set */
16%let config_set_id = %sysget(config_set_id);
17
18/* Server connection credentials */
19%let metaserver = %sysget(metaserver);
20%let sasAdminUser = %sysget(sasAdminUser);
21%let sasAdminPassword = %sysget(sasAdminPassword);
22
23/* Username and password used to register the Data Definition instance in RGF */
24%let sasUser = %sysget(sasUser);
25%let sasPassword = %sysget(sasPassword);
26
27/* Set Credentials */
28option
29 metaserver = "&metaserver."
30 metauser = "&sasAdminUser."
31 metapass = "&sasAdminPassword."
32;
33
34/* Data Repository Libref */
35%let dr_libref = RQSST;
36
37/* Get the path to the FA from metadata */
38%let irm_fa_path = %sysfunc(metadata_appprop(IRM Mid-Tier Server, com.sas.solutions.risk.irm.fa.&irm_fa_id.));
39%let irm_appdata_path = %sysfunc(metadata_appprop(IRM Mid-Tier Server, com.sas.solutions.risk.irm.server.appdata));
40
41/* Extract the irm folder name and the source path */
42%let fa_name = %scan(%bquote(&irm_fa_path.), -1, /\);
43%let source_path = %sysfunc(prxchange(s/[\\\/]&fa_name.$//i, -1, %bquote(&irm_fa_path.)));
44
45/* Update the macro search path */
46option insert = (sasautos = ("&irm_fa_path./source/sas/ucmacros"));
47option mprint;
48
49/* Setup environment */
50%irm_setup(source_path = &source_path.
51 , fa_id = &fa_name.
52 , rmc_fa_id = rmc.*
53 );
54
55%let rmc_fa_id = rmc.*;
56
57/* Get the list of RMC IRM federated areas matching the specified value */
58%irm_get_swc_property(swc_name = IRM Mid-Tier Server
59 , property = com.sas.solutions.risk.irm.fa.(?!readonly.)&rmc_fa_id.
60 , debug = true
61 , outvar = swc_property_value
62 , out_ds = irm_federated_areas
63 , pattern_match_flg = Y
64 );
65
66/* Sort in descending order */
67proc sort data = irm_federated_areas;
68 by descending property_name;
69run;
70
71/* Get the path to the RMC FA from metadata */
72%let rmc_fa_path =;
73
74data _null_;
75 set irm_federated_areas;
76 if _n_=1 then call symputx("rmc_fa_path", property_value, "L");
77run;
78
79/* Retrieve the content version from the version.txt file */
80%let content_version = %irm_get_content_version(irm_fa_path = &irm_fa_path.);
81
82/* Read run_option table */
83%include "&irm_fa_path./sampledata/config/%lowcase(&config_set_id.)/static/run_option.sas" / lrecl = 32000;
84
85/* Load global parameters */
86data _null_;
87 set run_option;
88 call symputx(config_name, config_value, "L");
89run;
90
91/* --------------------------------------------- */
92/* Get the connection details for the RGF Server */
93/* --------------------------------------------- */
94%irm_get_service_info(SWCName = Risk Gov Frwk Mid-Tier
95 , DeployedComponentName = Registered SAS Application
96 , ds_out = rgf_info
97 );
98data _null_;
99 set rgf_info;
100 call symputx("rgf_protocol", protocol, "G");
101 call symputx("rgf_host", host, "G");
102 call symputx("rgf_port", port, "G");
103 call symputx("rgf_service", ksubstr(service, 2), "G");
104run;
105
106/* --------------------------------------------- */
107/* Get the connection details for the RSM Server */
108/* --------------------------------------------- */
109%irm_get_service_info(SWCName = Risk Scenario Manager
110 , DeployedComponentName = Registered SAS Application
111 , ds_out = rsm_info
112 );
113data _null_;
114 set rsm_info;
115 call symputx("rsm_protocol", protocol, "G");
116 call symputx("rsm_host", host, "G");
117 call symputx("rsm_port", port, "G");
118 call symputx("rsm_service", ksubstr(service, 2), "G");
119run;
120
121/* ------------------------------ */
122/* Register data definitions */
123/* ------------------------------ */
124
125/* Read datastore configuration table */
126%let libref = work;
127%include "&irm_fa_path./sampledata/config/%lowcase(&config_set_id.)/static/datastore_config.sas" / lrecl = 32000;
128%include "&irm_fa_path./sampledata/config/%lowcase(&config_set_id.)/static/reportmart_config.sas" / lrecl = 32000;
129%include "&irm_fa_path./sampledata/config/%lowcase(&config_set_id.)/static/reportmart_aggregation_config.sas" / lrecl = 32000;
130
131/* Load data definitions in the staging folder */
132%let staging_ddls_to_load = cashflow collateral counterparty credit_synth_portfolio economic_sim loss_distribution_summary mitigation riskagg_linear_corr rwa_weights;
133%macro _create_data_defs();
134 %do i = 1 %to %sysfunc(countw(&staging_ddls_to_load.));
135 %let ddlName = %scan(&staging_ddls_to_load., &i.);
136 %let ticket =;
137 %irm_create_data_def_from_ddl(perspective_id = EWST
138 , table_name = &ddlName.
139 , ddl_file = &ddlName..sas
140 , ddl_folder = staging
141 , datastore_config = work.datastore_config
142 , ds_in_reportmart_config = work.reportmart_config
143 , ds_in_mart_aggregation_config = work.reportmart_aggregation_config
144 , irm_fa_path = &irm_fa_path.
145 , dr_libref = &dr_libref.
146 , rgf_solution = &rgf_solution.
147 , username = &sasUser.
148 , password = &sasPassword.
149 , rgf_protocol = &rgf_protocol.
150 , rgf_host = &rgf_host.
151 , rgf_port = &rgf_port.
152 , rgf_service = &rgf_service.
153 );
154 %end;
155%mend _create_data_defs;
156%_create_data_defs();
157
158/* --------------------------------------------------- */
159/* Register the Credit Risk Detail data definition */
160/* --------------------------------------------------- */
161%let ticket =;
162%irm_create_data_def_from_ddl(perspective_id = EWST
163 , table_name = credit_risk_detail
164 , ddl_file = credit_risk_detail.sas
165 , ddl_folder = reportmart
166 , datastore_config = work.datastore_config
167 , ds_in_reportmart_config = work.reportmart_config
168 , ds_in_mart_aggregation_config = work.reportmart_aggregation_config
169 , irm_fa_path = &irm_fa_path.
170 , dr_libref = &dr_libref.
171 , rgf_solution = &rgf_solution.
172 , username = &sasUser.
173 , password = &sasPassword.
174 , rgf_protocol = &rgf_protocol.
175 , rgf_host = &rgf_host.
176 , rgf_port = &rgf_port.
177 , rgf_service = &rgf_service.
178 );
179
180/* ----------------------------------------------------- */
181/* Register the Value at Risk Detail data definition */
182/* ----------------------------------------------------- */
183%let ticket =;
184%irm_create_data_def_from_ddl(perspective_id = EWST
185 , table_name = value_at_risk_detail
186 , ddl_file = value_at_risk_detail.sas
187 , ddl_folder = reportmart
188 , datastore_config = work.datastore_config
189 , ds_in_reportmart_config = work.reportmart_config
190 , ds_in_mart_aggregation_config = work.reportmart_aggregation_config
191 , irm_fa_path = &irm_fa_path.
192 , dr_libref = &dr_libref.
193 , rgf_solution = &rgf_solution.
194 , username = &sasUser.
195 , password = &sasPassword.
196 , rgf_protocol = &rgf_protocol.
197 , rgf_host = &rgf_host.
198 , rgf_port = &rgf_port.
199 , rgf_service = &rgf_service.
200 );
201
202/* ----------------------------------------- */
203/* Register the Portfolio data definition */
204/* ----------------------------------------- */
205
206/* Read staging and mapping tables for enrichment */
207%let libref = work;
208%let DTFMT = DATE9.;
209proc sql noprint;
210 %include "&irm_fa_path./source/sas/misc/ddl/staging/counterparty.sas" / lrecl = 32000;
211 %include "&irm_fa_path./source/sas/misc/ddl/mapping/map_geo_hierarchy.sas" / lrecl = 32000;
212 %include "&irm_fa_path./source/sas/misc/ddl/mapping/map_product_hierarchy.sas" / lrecl = 32000;
213 %include "&irm_fa_path./source/sas/misc/ddl/mapping/map_lob_hierarchy.sas" / lrecl = 32000;
214 %include "&irm_fa_path./source/sas/misc/ddl/mapping/map_dpd_type.sas" / lrecl = 32000;
215 %include "&irm_fa_path./source/sas/misc/ddl/mapping/map_ltv_type.sas" / lrecl = 32000;
216quit;
217
218/* Create an enrichment table containing all fields to add to Portfolio */
219data work.portfolio_enrichment;
220 attrib
221 %irm_get_attrib_def(ds_in = work.counterparty)
222 %irm_get_attrib_def(ds_in = map_geo_hierarchy)
223 %irm_get_attrib_def(ds_in = map_product_hierarchy)
224 %irm_get_attrib_def(ds_in = map_lob_hierarchy)
225 %irm_get_attrib_def(ds_in = map_dpd_type)
226 %irm_get_attrib_def(ds_in = map_ltv_type)
227 /* Additional fields from irmc_enrich_portfolio */
228 ORIG_CREDIT_STATE length = 8. label = "Credit State at origination"
229 CREDIT_STATE length = 8. label = "Current Credit State"
230 ;
231 stop;
232run;
233
234/* Store a list of fields to drop from the Portfolio table */
235%let ptf_drop_vars = geography_cd product_cd lob_id dpd_start dpd_end ltv_start ltv_end;
236
237/* Create Data Definition for Portfolio table */
238%let ticket =;
239%irm_create_data_def_from_ddl(perspective_id = EWST
240 , table_name = credit_portfolio
241 , ddl_file = credit_portfolio.sas
242 , ddl_folder = staging
243 , datastore_config = work.datastore_config
244 , enrichment_table = work.portfolio_enrichment
245 , drop_vars = &ptf_drop_vars.
246 , irm_fa_path = &irm_fa_path.
247 , dr_libref = &dr_libref.
248 , outds = data_definition_ptf
249 , rgf_solution = &rgf_solution.
250 , username = &sasUser.
251 , password = &sasPassword.
252 , rgf_protocol = &rgf_protocol.
253 , rgf_host = &rgf_host.
254 , rgf_port = &rgf_port.
255 , rgf_service = &rgf_service.
256 );
257
258/* ---------------------------------------------- */
259/* Register the FS/CA/OF/PL/GL data definitions */
260/* ---------------------------------------------- */
261
262/* Create Data Definition for FS Projection reportmart table */
263%let ticket =;
264%let httpSuccess = 0;
265%let responseStatus =;
266%irm_create_data_def_from_ddl(perspective_id = EWST
267 , table_name = fs_projection
268 , ddl_file = fs_projection.sas
269 , ddl_folder = reportmart
270 , datastore_config = work.datastore_config
271 , irm_fa_path = &irm_fa_path.
272 , dr_libref = &dr_libref.
273 , rgf_solution = &rgf_solution.
274 , username = &sasUser.
275 , password = &sasPassword.
276 , rgf_protocol = &rgf_protocol.
277 , rgf_host = &rgf_host.
278 , rgf_port = &rgf_port.
279 , rgf_service = &rgf_service.
280 , outds = schema_info_fs
281 , outSuccess = httpSuccess
282 , outResponseStatus = responseStatus
283 );
284/* Store the data definition id of the FS Projection data definition */
285%if(&httpSuccess. and %rsk_dsexist(schema_info_fs)) %then %do;
286 data _null_;
287 set schema_info_fs;
288 call symputx("fs_data_def_key", key, "L");
289 run;
290%end;
291
292/* Create Data Definition for Capital Adequacy Summary reportmart table */
293%let ticket =;
294%let httpSuccess = 0;
295%let responseStatus =;
296%irm_create_data_def_from_ddl(perspective_id = EWST
297 , table_name = capital_adequacy_summary
298 , ddl_file = capital_adequacy_summary.sas
299 , ddl_folder = reportmart
300 , datastore_config = work.datastore_config
301 , irm_fa_path = &irm_fa_path.
302 , dr_libref = &dr_libref.
303 , rgf_solution = &rgf_solution.
304 , username = &sasUser.
305 , password = &sasPassword.
306 , rgf_protocol = &rgf_protocol.
307 , rgf_host = &rgf_host.
308 , rgf_port = &rgf_port.
309 , rgf_service = &rgf_service.
310 , outds = schema_info_ca
311 , outSuccess = httpSuccess
312 , outResponseStatus = responseStatus
313 );
314/* Store the data definition id of the Capital Adequacy Summary data definition */
315%if(&httpSuccess. and %rsk_dsexist(schema_info_ca)) %then %do;
316 data _null_;
317 set schema_info_ca;
318 call symputx("ca_data_def_key", key, "L");
319 run;
320%end;
321
322/* Read staging and mapping tables for enrichment */
323%let libref = work;
324%let DTFMT = DATE9.;
325proc sql noprint;
326 %include "&irm_fa_path./source/sas/misc/ddl/mapping/map_profit_loss_hierarchy.sas" / lrecl = 32000;
327 %include "&irm_fa_path./source/sas/misc/ddl/mapping/map_balance_sheet_hierarchy.sas" / lrecl = 32000;
328 %include "&irm_fa_path./source/sas/misc/ddl/mapping/map_own_funds_hierarchy.sas" / lrecl = 32000;
329 %include "&irm_fa_path./source/sas/misc/ddl/mapping/map_geo_hierarchy.sas" / lrecl = 32000;
330 %include "&irm_fa_path./source/sas/misc/ddl/mapping/map_chart_of_account.sas" / lrecl = 32000;
331 %include "&irm_fa_path./source/sas/misc/ddl/mapping/map_movement_type.sas" / lrecl = 32000;
332quit;
333
334/* Create an enrichment table containing all fields to add to the Profit & Loss table */
335data work.pl_enrichment;
336 attrib
337 %irm_get_attrib_def(ds_in = map_geo_hierarchy, drop_vars = geography_cd)
338 %irm_get_attrib_def(ds_in = map_profit_loss_hierarchy, drop_vars = chart_of_account_cd balance_sheet_cd profit_loss_cd own_funds_cd)
339 %irm_get_attrib_def(ds_in = map_chart_of_account, keep_vars = chart_of_account_name)
340 %irm_get_attrib_def(ds_in = map_movement_type, drop_vars = movement_type_cd)
341 ;
342 stop;
343run;
344
345/* Create Data Definition for Profit & Loss staging table */
346%let ticket =;
347%let httpSuccess = 0;
348%let responseStatus =;
349%irm_create_data_def_from_ddl(perspective_id = EWST
350 , table_name = profit_loss_account
351 , ddl_file = profit_loss_account.sas
352 , ddl_folder = staging
353 , datastore_config = work.datastore_config
354 , enrichment_table = work.pl_enrichment
355 , irm_fa_path = &irm_fa_path.
356 , dr_libref = &dr_libref.
357 , rgf_solution = &rgf_solution.
358 , username = &sasUser.
359 , password = &sasPassword.
360 , rgf_protocol = &rgf_protocol.
361 , rgf_host = &rgf_host.
362 , rgf_port = &rgf_port.
363 , rgf_service = &rgf_service.
364 , outds = schema_info_pl
365 , outSuccess = httpSuccess
366 , outResponseStatus = responseStatus
367 );
368
369/* Store the data definition id of the PL data definition */
370%if(&httpSuccess. and %rsk_dsexist(schema_info_pl)) %then %do;
371 data _null_;
372 set schema_info_pl;
373 call symputx("pl_data_def_key", key, "L");
374 run;
375%end;
376
377/* Create an enrichment table containing all fields to add to the General Ledger table */
378data work.gl_enrichment;
379 attrib
380 %irm_get_attrib_def(ds_in = map_geo_hierarchy, drop_vars = geography_cd)
381 %irm_get_attrib_def(ds_in = map_balance_sheet_hierarchy, drop_vars = chart_of_account_cd balance_sheet_cd profit_loss_cd own_funds_cd)
382 %irm_get_attrib_def(ds_in = map_chart_of_account, keep_vars = chart_of_account_name)
383 %irm_get_attrib_def(ds_in = map_movement_type, drop_vars = movement_type_cd)
384 ;
385 stop;
386run;
387
388/* Create Data Definition for General Ledger staging table */
389%let ticket =;
390%let httpSuccess = 0;
391%let responseStatus =;
392%irm_create_data_def_from_ddl(perspective_id = EWST
393 , table_name = gl_account
394 , ddl_file = gl_account.sas
395 , ddl_folder = staging
396 , datastore_config = work.datastore_config
397 , enrichment_table = work.gl_enrichment
398 , irm_fa_path = &irm_fa_path.
399 , dr_libref = &dr_libref.
400 , rgf_solution = &rgf_solution.
401 , username = &sasUser.
402 , password = &sasPassword.
403 , rgf_protocol = &rgf_protocol.
404 , rgf_host = &rgf_host.
405 , rgf_port = &rgf_port.
406 , rgf_service = &rgf_service.
407 , outds = schema_info_gl
408 , outSuccess = httpSuccess
409 , outResponseStatus = responseStatus
410 );
411/* Store the data definition id of the GL data definition */
412%if(&httpSuccess. and %rsk_dsexist(schema_info_gl)) %then %do;
413 data _null_;
414 set schema_info_gl;
415 call symputx("gl_data_def_key", key, "L");
416 run;
417%end;
418
419/* Create an enrichment table containing all fields to add to the General Ledger table */
420data work.of_enrichment;
421 attrib
422 %irm_get_attrib_def(ds_in = map_geo_hierarchy, drop_vars = geography_cd)
423 %irm_get_attrib_def(ds_in = map_own_funds_hierarchy, drop_vars = chart_of_account_cd balance_sheet_cd profit_loss_cd own_funds_cd)
424 %irm_get_attrib_def(ds_in = map_chart_of_account, keep_vars = chart_of_account_name)
425 %irm_get_attrib_def(ds_in = map_movement_type, drop_vars = movement_type_cd)
426 ;
427 stop;
428run;
429
430/* Create Data Definition for Own Funds staging table */
431%let ticket =;
432%let httpSuccess = 0;
433%let responseStatus =;
434%irm_create_data_def_from_ddl(perspective_id = EWST
435 , table_name = own_funds_account
436 , ddl_file = own_funds_account.sas
437 , ddl_folder = staging
438 , datastore_config = work.datastore_config
439 , enrichment_table = work.of_enrichment
440 , irm_fa_path = &irm_fa_path.
441 , dr_libref = &dr_libref.
442 , rgf_solution = &rgf_solution.
443 , username = &sasUser.
444 , password = &sasPassword.
445 , rgf_protocol = &rgf_protocol.
446 , rgf_host = &rgf_host.
447 , rgf_port = &rgf_port.
448 , rgf_service = &rgf_service.
449 , outds = schema_info_of
450 , outSuccess = httpSuccess
451 , outResponseStatus = responseStatus
452 );
453/* Store the data definition id of the OF data definition */
454%if(&httpSuccess. and %rsk_dsexist(schema_info_of)) %then %do;
455 data _null_;
456 set schema_info_of;
457 call symputx("of_data_def_key", key, "L");
458 run;
459%end;
460
461/* ********************************************************* */
462/* Add link instances for the data maps / data definitions */
463/* ********************************************************* */
464
465/* Get all data map instances */
466%let ticket =;
467%let httpSuccess = 0;
468%let responseStatus =;
469%irm_rest_get_rgf_data_map(host = &rgf_protocol.://&rgf_host.
470 , server = &rgf_service.
471 , solution = &rgf_solution.
472 , port = &rgf_port.
473 , username = &sasUser.
474 , password = &sasPassword.
475 , outds = dataMap_summary
476 , outds_details = dataMap_details
477 , outVarTicket = ticket
478 , outSuccess = httpSuccess
479 , outResponseStatus = responseStatus
480 );
481/* Pull the data map keys using the data map ids */
482%if(&httpSuccess. and %rsk_dsexist(dataMap_summary)) %then %do;
483 data _null_;
484 set dataMap_summary;
485 if objectId eq "ST-0821-DataMap-OF" then call symputx("of_data_map_key", key, "L");
486 if objectId eq "ST-0821-DataMap-PL" then call symputx("pl_data_map_key", key, "L");
487 if objectId eq "ST-0821-DataMap-GL" then call symputx("gl_data_map_key", key, "L");
488 run;
489%end;
490
491%macro create_data_map_links(link_type, bo1_key, bo2_key);
492 /* Get the link type key in order to create a unique link instance id less than 32 chars */
493 %let ticket=;
494 %irm_rest_get_rgf_link_types(host = &rgf_protocol.://&rgf_host.
495 , server = &rgf_service.
496 , solution = &rgf_solution.
497 , port = &rgf_port.
498 , filter = linkTypeId=&link_type.
499 , outds = link_type
500 , username = &sasUser.
501 , password = &sasPassword.
502 , outVarTicket = ticket
503 , outSuccess = httpSuccess
504 , outResponseStatus = responseStatus
505 );
506 %if (&httpSuccess. and %rsk_dsexist(link_type)) %then %do;
507 data _null_;
508 set link_type;
509 call symputx("link_type_key", key, "L");
510 run;
511
512 /* Check if the link instance already exists */
513 %let ticket=;
514 %irm_rest_get_rgf_link_instances(host = &rgf_protocol.://&rgf_host.
515 , server = &rgf_service.
516 , solution = &rgf_solution.
517 , port = &rgf_port.
518 , filter = linkInstanceId=&link_type_key._&bo1_key._&bo2_key.
519 , outds = link_instances
520 , username = &sasUser.
521 , password = &sasPassword.
522 , outVarTicket = ticket
523 , outSuccess = httpSuccess
524 , outResponseStatus = responseStatus
525 );
526
527 %if (&httpSuccess. and %rsk_attrn(link_instances, nobs) eq 0) %then %do;
528 /* Link instance does not exist - create the link instance */
529 %let ticket=;
530 %irm_rest_create_rgf_link_inst(host = &rgf_protocol.://&rgf_host.
531 , server = &rgf_service.
532 , solution = &rgf_solution.
533 , port = &rgf_port.
534 , username = &sasUser.
535 , password = &sasPassword.
536 , link_instance_id = &link_type_key._&bo1_key._&bo2_key.
537 , link_type = &link_type.
538 , business_object1 = &bo1_key.
539 , business_object2 = &bo2_key.
540 , outds = link_instance
541 , outVarTicket = ticket
542 , outSuccess = httpSuccess
543 , outResponseStatus = responseStatus
544 );
545 %end;
546 %end;
547%mend;
548
549/* Create the link instances between data maps and data definitions */
550%if (%symexist(of_data_def_key) and %symexist(pl_data_def_key) and %symexist(gl_data_def_key) and %symexist(fs_data_def_key)) %then %do;
551 %create_data_map_links(link_type = dataMap_dataDefinition_src, bo1_key = &of_data_map_key., bo2_key = &of_data_def_key.);
552 %create_data_map_links(link_type = dataMap_dataDefinition_tgt, bo1_key = &of_data_map_key., bo2_key = &fs_data_def_key.);
553 %create_data_map_links(link_type = dataMap_dataDefinition_src, bo1_key = &pl_data_map_key., bo2_key = &pl_data_def_key.);
554 %create_data_map_links(link_type = dataMap_dataDefinition_tgt, bo1_key = &pl_data_map_key., bo2_key = &fs_data_def_key.);
555 %create_data_map_links(link_type = dataMap_dataDefinition_src, bo1_key = &gl_data_map_key., bo2_key = &gl_data_def_key.);
556 %create_data_map_links(link_type = dataMap_dataDefinition_tgt, bo1_key = &gl_data_map_key., bo2_key = &fs_data_def_key.);
557%end;
558%else %do;
559 %put WARNING: Could not load link instances for Data Maps because required Data Definition Ids were not found.;
560%end;
561
562/* ************************************************* */
563/* Register Data Quality (DQ) rules */
564/* ************************************************* */
565
566/* Load DQ rules */
567%include "&irm_fa_path./sampledata/config/%lowcase(&config_set_id.)/static/rule_set_config.sas" / lrecl = 32000;
568data dq_rule_set_config;
569 set rule_set_config (where = (rule_set_group_id = "CREDIT_PORTFOLIO"));
570run;
571
572/* Get EWST dimensional_points to assign perspective created in */
573%let ticket =;
574%let dim_point_key=;
575%let httpSuccess = 0;
576%let responseStatus =;
577%irmc_get_dim_point_from_groovy(query_type = emptyLocationWithPerspectiveNodes
578 , perspective_id = EWST
579 , outVar = dim_point_key
580 , host = &rgf_protocol://&rgf_host.
581 , server = &rgf_service.
582 , solution = &rgf_solution.
583 , port = &rgf_port.
584 , username = &sasUser.
585 , password = &sasPassword.
586 , outVarTicket = ticket
587 , outSuccess = httpSuccess
588 , outResponseStatus = responseStatus
589 );
590/* Create RuleSet */
591%let ticket =;
592%irm_rest_create_rgf_ruleset(host = &rgf_protocol://&rgf_host.
593 , server = &rgf_service.
594 , solution = &rgf_solution.
595 , dimensional_points = %quote(&dim_point_key.)
596 , port = &rgf_port.
597 , username = &sasUser.
598 , password = &sasPassword.
599 , name = DQ Rule Set - &content_version.
600 , description = Sample Data Quality rules
601 , ds_in = dq_rule_set_config
602 , ruleset_type = BusinessRuleSet
603 , ruleset_category = DQ
604 , outds = ruleSetInfoDQ
605 , outVarTicket = ticket
606 , outSuccess = httpSuccess
607 , outResponseStatus = responseStatus
608 , debug = false
609 , logOptions =
610 , restartLUA = Y
611 , clearCache = Y
612 );
613
614/* Get the rule set key */
615%let rule_set_dq_key =;
616data _null_;
617 set ruleSetInfoDQ(obs = 1);
618 call symputx("rule_set_dq_key", ruleSetKey, "L");
619run;
620
621/* Get the data definition key */
622%let data_def_ptf_key =;
623data _null_;
624 set data_definition_ptf;
625 call symputx("data_def_ptf_key", key, "L");
626run;
627
628/* Create the 360 link between the Rule Set and the Data Definition */
629%let ticket =;
630%irm_rest_create_rgf_link_inst(host = &rgf_protocol.://&rgf_host.
631 , server = &rgf_service.
632 , solution = &rgf_solution.
633 , port = &rgf_port.
634 , username = &sasUser.
635 , password = &sasPassword.
636 , link_type = ruleSet_dataDefinition
637 , business_object1 = &rule_set_dq_key.
638 , business_object2 = &data_def_ptf_key.
639 , outds = rule_dq_link_instance
640 , outVarTicket = ticket
641 , outSuccess = httpSuccess
642 , outResponseStatus = responseStatus
643 , restartLUA = Y
644 , clearCache = Y
645 );
646
647/* ************************************************* */
648/* Load VA report configuration table */
649/* ************************************************* */
650
651/* Set Reportmart library */
652%let libref = MART_DP;
653libname &libref. meta liburi = "SASLibrary?@Name = '&mart_library_name.'" metaout = data;
654
655/* Create VA report configuration data structure */
656proc sql;
657%include "&irm_fa_path./source/sas/misc/ddl/static/va_report_config.sas" / lrecl = 32000;
658quit;
659proc datasets library = &libref. nolist nodetails nowarn;
660 delete st_va_report_config;
661 change va_report_config = st_va_report_config;
662quit;
663
664/* Load configuration data */
665%include "&irm_fa_path./sampledata/config/%lowcase(&config_set_id.)/static/va_report_config.sas" / lrecl = 32000;
666proc append
667 base = &libref..st_va_report_config
668 data = va_report_config;
669run;
670
671/* Load to LASR */
672%irm_upload_to_lasr(ds_in = &libref..st_va_report_config
673 , lasr_library_name = &lasr_library_name.
674 , target_table_nm = st_va_report_config
675 , meta_repository = Foundation
676 , meta_folder = &lasr_meta_folder.
677 , mode = replace
678 , squeeze = yes
679 );
680
681/* ******************************************************************************************************************************************************************** */
682/* Run the finalize block of the existing Cycles for each perspective_id (if they have a linked control frameworks) to create the &perspective_id._cntrlRules_ tables */
683/* ******************************************************************************************************************************************************************** */
684%let perspective_id_lst=%str(EWST,ICAAP,CCAR);
685%let num_perspective_ids = %sysfunc(countw(&perspective_id_lst., %str(,)));
686
687%macro init_cycle();
688
689 /* Loop through the perspective_id_lst initialize the cycles, create the reportmart tables and load the tables to LASR */
690 %do p = 1 %to &num_perspective_ids.;
691
692 /* Get the perspective_id */
693 %let perspective_id=%scan(&perspective_id_lst.,&p.,%str(,));
694
695 /* Get any cycles that have a control framework linked to them and are in the 'init' step */
696 %let ticket =;
697 %irm_rest_get_rgf_cycle(host = &rgf_protocol://&rgf_host.
698 , port = &rgf_port.
699 , server = &rgf_service.
700 , username = &sasUser.
701 , password = &sasPassword.
702 , filter = filter=and(hasObjectLinkToEq(%27RMC%27,%27cycle_controlFramework%27,%27solutionCreatedIn%27,%27%upcase(&perspective_id.)%27,0),eq(statusCd,%27init%27))
703 , outds = cycle_ds
704 );
705
706 /* Read the cycle information */
707 %let tot_cycles = 0;
708 data _null_;
709 set cycle_ds end=last;
710 call symputx(cats("cycle_key_", put(_N_, 8.)), key, "L");
711 if last then
712 call symputx("tot_cycles", _N_, "L");
713 run;
714
715 /***********************************/
716 /* Initalize the reportmart tables */
717 /***********************************/
718 %let libref=work;
719 proc sql;
720 %include "&rmc_fa_path./source/sas/misc/ddl/reportmart/control_execution_results.sas";
721 %include "&rmc_fa_path./source/sas/misc/ddl/reportmart/control_limit_results.sas";
722 quit;
723
724 /****************************************************************************/
725 /* Loop through the cycles to create the cntrlRules tables and load to LASR */
726 /****************************************************************************/
727 %let baseRequestUrl = &rgf_protocol://&rgf_host.:&rgf_port./&rgf_service./rest/&rgf_solution.;
728 %let uiRequestUrl = &baseRequestUrl.-%lowcase(&perspective_id.)/uiContexts/cycles;
729
730 /* Loop through each cycle and send a PUT request to run the finalize block which creates the cntrlRules tables */
731 %do c = 1 %to &tot_cycles.;
732
733 /* Make sure the payload file is empty */
734 filename payload temp;
735 data _null_;
736 file payload;
737 put;
738 run;
739
740 %let ticket =;
741 %let httpSuccess = 0;
742 %let responseStatus =;
743 /* Retrieve the cycle payload and set TEMP.CREATEDINBATCH to true */
744 %irm_rest_request(url = &uiRequestUrl./&&cycle_key_&c..
745 , method = POST
746 , server = &rgf_service.
747 , username = &sasUser.
748 , password = &sasPassword.
749 , headerIn = Accept:application/json
750 , body = %bquote({"SCREENID": "CustomObject214", "TEMP.CREATEDINBATCH": true})
751 , parser =
752 , outds =
753 , fout = payload
754 , outVarTicket = ticket
755 , outSuccess = httpSuccess
756 , outResponseStatus = responseStatus
757 );
758
759 %if &httpSuccess ne 1 %then %do;
760 %abort;
761 %put "Execution stopped due to errors.";
762 %end;
763
764 %let ticket =;
765 %let httpSuccess = 0;
766 %let responseStatus =;
767 /* Send a put request to run the finalize block */
768 %irm_rest_request(url = &uiRequestUrl./&&cycle_key_&c..
769 , method = PUT
770 , server = &rgf_service.
771 , username = &sasUser.
772 , password = &sasPassword.
773 , headerIn = Accept:application/json
774 , body = payload
775 , parser =
776 , outds =
777 , outVarTicket = ticket
778 , outSuccess = httpSuccess
779 , outResponseStatus = responseStatus
780 );
781 %if &httpSuccess ne 1 %then %do;
782 %abort;
783 %put "Error updating cycle to create control rules tables. Execution stopped due to errors.";
784 %end;
785
786 /* Clear out the payload file */
787 filename payload clear;
788
789 /* Load the control exec & limit results to LASR */
790 %irm_upload_to_lasr(ds_in =work.control_execution_results
791 , lasr_library_name = &lasr_library_name.
792 , target_table_nm = &perspective_id._CNTRL_EXEC_RESULTS
793 , meta_repository = &meta_repository.
794 , meta_folder = &lasr_meta_folder.
795 , mode = append
796 );
797
798 %irm_upload_to_lasr(ds_in =work.control_limit_results
799 , lasr_library_name = &lasr_library_name.
800 , target_table_nm = &perspective_id._CNTRL_LIMIT_RESULTS
801 , meta_repository = &meta_repository.
802 , meta_folder = &lasr_meta_folder.
803 , mode = append
804 );
805 %end; /* End tot_cycles loop */
806 %end; /* End perspective_id_lst loop */
807%mend;
808%init_cycle();