SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_node_aggregate_from_rules.sas
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 SAS Institute Inc. Cary, NC, USA
3*/
4
5/** \file
6 \brief Calculate the aggregated values and apply them to the target table
7
8 \param[in] ST_PRM.RUN_OPTION parameter table
9 \param[in] %ds_in_dq_config = ST_STG.DQ_CONFIG Input table containing a record for each combination of AnalysisData key and RuleSet key
10 \param[in] %ds_in_agg_rules_config = ST_CFG.AGGREGATION_RULES_CONFIG Contains the rules for aggregating the portfolio results
11 \param[out] %ds_out_base = ST_STG.ST_GL_ACCOUNT_BASE Ouput base dataset
12 \param[out] %ds_out_agg = ST_STG.ST_GL_ACCOUNT_AGG Ouput aggregated dataset
13
14 \details
15
16 This node applies the aggregation rules from the aggregation_rules_config table to the source table and adds the aggregations to the target table for comparison
17
18 The following macro utilities are called:
19
20 | Macro name | Description | Further information |
21 |----------------------------|--------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
22 | irm_session_prepare | Reads RUN_OPTION table and sets logging options | \link irm_session_prepare.sas \endlink |
23 | irm_session_cleanup | Removes all non-IRM WORK datasets/views and deletes all user-created macro variables from workspace session | \link irm_session_cleanup.sas \endlink |
24 | irmst_aggregate_from_rules | Calculates the aggregation values from the source table based on rules in %ds_in_agg_rules_config | \link irmst_aggregate_from_rules.sas \endlink |
25 | irmst_apply_agg | Apply aggregation values to the target table | \link irmst_apply_agg.sas \endlink |
26
27 \ingroup nodes
28 \author SAS Institute Inc.
29 \date 2018
30*/
31
32/* Initialize session */
33%irm_session_prepare();
34
35/* Initialize macro so %do loops can be used */
36%macro irmst_node_aggregate_from_rules(ds_in_dq_config =
37 , ds_in_agg_rules_config =
38 , ds_out_base =
39 , ds_out_agg =
40 );
41
42 data _null_;
43 set &ds_in_dq_config.;
44 call symputx("gl_reconciliation_flg", gl_reconciliation_flg, "L");
45 call symputx("portfolio_key", analysis_data_key, "L");
46 call symputx("general_ledger_key", general_ledger_key, "L");
47 run;
48
49 %if(%sysevalf(%superq(gl_reconciliation_flg) = Y, boolean) and
50 %sysevalf(%superq(general_ledger_key) ne, boolean)) %then %do;
51
52 /* Perform Aggregation */
53
54 %let ticket =;
55 %let httpSuccess = 0;
56 %let responseStatus =;
57 /* Retrieve target analysis data */
58 %irm_rgf_retrieve_analysis_data(key = &general_ledger_key.
59 , libref = rqsst
60 , outds = WORK.TARGET_DATA
61 , outds_partition_list = partition_list
62 , out_type = deferred
63 , outds_dataInfo = target_dataInfo
64 , outds_dataDef = target_dataDef
65 , host = &rgf_protocol.://&rgf_host.
66 , server = &rgf_service.
67 , solution = rmc
68 , port = &rgf_port.
69 , tgt_ticket = &tgt_ticket.
70 , outVarTicket = ticket
71 , outSuccess = httpSuccess
72 , outResponseStatus = responseStatus
73 , restartLUA = Y
74 , clearCache = Y
75 );
76
77 data _null_;
78 set target_dataDef (obs=1);
79 call symputx("tgt_table_schema_nm", upcase(schemaName), "L");
80 call symputx("tgt_table_schema_ver", upcase(schemaVersion), "L");
81 run;
82
83 data &ds_out_base.;
84 set WORK.TARGET_DATA;
85 run;
86
87 %let httpSuccess = 0;
88 %let responseStatus =;
89 /* Retrieve source analysis data */
90 %irm_rgf_retrieve_analysis_data(key = &portfolio_key.
91 , libref = rqsst
92 , outds = WORK.SOURCE_DATA
93 , outds_partition_list = partition_list
94 , out_type = deferred
95 , outds_dataInfo = source_dataInfo
96 , outds_dataDef = source_dataDef
97 , host = &rgf_protocol.://&rgf_host.
98 , server = &rgf_service.
99 , solution = rmc
100 , port = &rgf_port.
101 , tgt_ticket = &tgt_ticket.
102 , outVarTicket = ticket
103 , outSuccess = httpSuccess
104 , outResponseStatus = responseStatus
105 , restartLUA = Y
106 , clearCache = Y
107 );
108
109 data _null_;
110 set source_dataDef (obs=1);
111 call symputx("src_table_schema_nm", upcase(schemaName), "L");
112 call symputx("src_table_schema_ver", upcase(schemaVersion), "L");
113 run;
114
115 /* Resolve the schema version in the aggregation rules config table and filter based on analysis data schema information */
116 data WORK.AGGREGATION_RULES_CONFIG;
117 set &ds_in_agg_rules_config.;
118 tgt_table_schema_ver = resolve(tgt_table_schema_ver);
119 src_table_schema_ver = resolve(src_table_schema_ver);
120 if upcase(tgt_table_schema_nm) = "&tgt_table_schema_nm." and
121 upcase(tgt_table_schema_ver) = "&tgt_table_schema_ver." and
122 upcase(src_table_schema_nm) = "&src_table_schema_nm." and
123 upcase(src_table_schema_ver) = "&src_table_schema_ver.";
124 run;
125
126 %if %rsk_attrn(WORK.AGGREGATION_RULES_CONFIG, nlobs) > 0 %then %do;
127
128 /* Run aggregation of source table */
129 %irmst_aggregate_from_rules(ds_in_src_tbl = WORK.SOURCE_DATA
130 , ds_in_agg_rules_config = WORK.AGGREGATION_RULES_CONFIG
131 , out_ds = WORK.AGGREGATED_VALUES
132 );
133
134 /* Apply aggregation to target table */
135 %irmst_apply_agg(ds_in_agg = WORK.AGGREGATED_VALUES
136 , ds_in_tgt = &ds_out_base.
137 , ds_in_agg_rules_config = WORK.AGGREGATION_RULES_CONFIG
138 , ds_out = &ds_out_agg.
139 );
140
141 %end;
142
143 %end;
144
145 %if(not %rsk_dsexist(&ds_out_base.) or not %rsk_dsexist(&ds_out_agg.)) %then %do;
146
147 /* Ouput the base and aggregated datasets without calculations */
148
149 data &ds_out_base. &ds_out_agg.;
150 gl_reconciliation_flg = "&gl_reconciliation_flg.";
151 general_ledger_key = &general_ledger_key.;
152 run;
153
154 %end;
155
156%mend;
157
158/* Run newly initialized macro */
159%irmst_node_aggregate_from_rules(ds_in_dq_config = &ds_in_dq_config.
160 , ds_in_agg_rules_config = &ds_in_agg_rules_config.
161 , ds_out_base = &ds_out_base.
162 , ds_out_agg = &ds_out_agg.
163 );
164
165/* Cleanup session */
166%irm_session_cleanup;