SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_node_apply_aggregation.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_bep_summary = ST_STG.BEP_SUMMARY Input table containing a list of the Business Evolution Plans associated with this Analysis Run
10 \param[in] %ds_in_bep_details = ST_STG.BEP_DETAILS Input table containing details of the Business Evolution Plans associated with this Analysis Run
11 \param[in] %ds_in_agg_rules_config = P_ST_CFG.AGGREGATION_RULES_CONFIG Contains the rules for aggregating the credit risk detail results
12 \param[in] %ds_in_bsp_data_config = P_ST_CFG.BSP_DATA_CONFIG Contains information on the source table and scenario name
13 \param[in] %ds_in_src_tbl_detail = P_ST_CFG.AGG_SRC_TBL The source table where aggetation will take place.
14 \param[out] %ds_out_sync_tbls_info = P_ST_STG.RSLT_TBLS_INFO Output table needed for syncronization
15
16 \details
17
18 This node retrieves the target data and applies the aggregation rules from the aggregation_rules_config table it creates the target tables
19 in the same directory as &ds_out_sync_tbls_info.
20
21 The following macro utilities are called:
22
23 | Macro name | Description | Further information |
24 |-------------------------------|--------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
25 | irm_session_prepare | Reads RUN_OPTION table and sets logging options | \link irm_session_prepare.sas \endlink |
26 | 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 |
27 | irmst_calculate_agg_bep_value | Calculates the aggregation value using the configuration table | \link irmst_calculate_agg_bep_value.sas \endlink|
28 | irmst_apply_aggregation | Applies the calculated aggregated value | \link irmst_apply_aggregation.sas \endlink |
29
30 \ingroup nodes
31 \author SAS Institute Inc.
32 \date 2018
33*/
34
35/* Initialize session */
36%irm_session_prepare();
37
38data _null_;
39 set &ds_in_bsp_data_config.;
40 call symputx("source_data_name",source_data_name , "L");
41 call symputx("source_data_version",source_data_version , "L");
42 call symputx("analysis_data_key",analysis_data_key , "L");
43 call symputx("scenario_name", scenario_name, "L");
44run;
45
46data agg_rules_config_enrchd (drop=cntr);
47 length src_col $32.;
48 set &ds_in_agg_rules_config.;
49 retain cntr 0;
50 by weight_var;
51 if first.weight_var then do;
52 cntr=cntr+1;
53 end;
54 if WEIGHT_VAR not = " " then do;
55 src_col=cats(trim(src_col),'_w',trim(cntr)-1);
56 end;
57run;
58
59/* Expand the BEP summary table to one record per planning data */
60data work.bep_summary_exp;
61 set &ds_in_bep_summary.;
62 original_targetVariable = targetVariable;
63 original_accountID = accountID;
64 original_planningDataKey = planningDataKey;
65 original_dataDefSchemaName = dataDefSchemaName;
66 original_dataDefSchemaVersion = dataDefSchemaVersion;
67 do i=1 to countw(original_targetVariable,",");
68 targetVariable = scan(original_targetVariable,i,",");
69 accountID = scan(original_accountID,i,",");
70 planningDataKey = scan(original_planningDataKey,i,",");
71 dataDefSchemaName = scan(original_dataDefSchemaName,i,",");
72 dataDefSchemaVersion = scan(original_dataDefSchemaVersion,i,",");
73 output;
74 end;
75 drop original_: i;
76run;
77
78/* Aggregate the values in credit risk detail using the aggregation rules */
79%irmst_calculate_agg_bep_value( ds_in = &ds_in_src_tbl_detail.
80 , ds_in_agg_rules = &ds_in_agg_rules_config.
81 , ds_in_agg_rules_enrchd = agg_rules_config_enrchd
82 , ds_out = work.aggregated_values);
83
84/* Apply the aggregated values to the planning data from the BSP */
85%let out_libref = %scan(&ds_out_sync_tbls_info., 1, %str(.));
86%irmst_apply_aggregation(ds_in_bep_summary = work.bep_summary_exp
87 , ds_in_agg_values = work.aggregated_values
88 , ds_in_agg_rules = agg_rules_config_enrchd
89 , out_libref = &out_libref.
90 );
91
92/* Create the output tbls_info table */
93data &ds_out_sync_tbls_info.;
94 DONE='done';
95run;
96
97/* Cleanup session */
98%irm_session_cleanup;