SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_get_unagg_data.sas
1%macro irmst_get_unagg_data(ds_in_agg_rules_config=,
2 ds_in_bep_summary=,
3 ds_in_bsp_data_config=,
4 out_libref=,
5 ds_out_info_tbl=,
6 );
7
8
9proc sql noprint;
10
11 create table work.ds_out_agg_rules_config as
12 select config.*
13 from
14 (select rules.*
15 from &ds_in_agg_rules_config. as rules
16 inner join &ds_in_bep_summary. as summary
17 on upcase(rules.tgt_table_schema_nm) = upcase(summary.dataDefSchemaName)
18 and upcase(rules.src_table_schema_nm) ne upcase(rules.tgt_table_schema_nm)
19 and upcase(resolve(rules.tgt_table_schema_ver)) = upcase(resolve(summary.dataDefSchemaVersion))
20 ) as config, &ds_in_bsp_data_config. as bsp_cfg
21 where upcase(config.src_table_schema_nm) = upcase(bsp_cfg.source_data_name)
22 and upcase(resolve(config.src_table_schema_ver)) = upcase(bsp_cfg.source_data_version)
23 ;
24
25quit;
26 /* Set up the data extraction table to pull the planning data */
27 data work.data_extraction_config;
28 set &ds_in_bep_summary. (keep = planningDataKey dataDefSchemaName)
29 end = last;
30 keep source_data_name
31 analysis_data_key
32 aggregate_flg
33 ;
34 /* Store the fields needed for irm_rgf_retrieve_data */
35 source_data_name = dataDefSchemaName;
36 analysis_data_key = planningDataKey;
37 aggregate_flg = "N";
38 /* Store the planning data schema name */
39 call symputx(cats("planning_data_", put(_N_, 8.)), dataDefSchemaName, "L");
40 /* Store the number of planning data keys found */
41 if last then call symputx("n_keys", _N_, "L");
42 run;
43
44 /* Store a backup of out_libref since it gets reassigned in the next macro call */
45 %let out_libref_tmp = &out_libref.;
46
47 /* Retrieve all analysis data */
48 %irm_rgf_retrieve_data(dr_libref = &dr_libref.
49 , dr_library_name = &dr_library_name.
50 , ds_in = work.data_extraction_config
51 , ds_out = work.export_summary
52 , out_type = data
53 , rgf_protocol = &rgf_protocol.
54 , rgf_host = &rgf_host.
55 , rgf_service = &rgf_service.
56 , rgf_solution = &rgf_solution.
57 , rgf_port = &rgf_port.
58 , tgt_ticket = &tgt_ticket.
59 );
60
61 /* Reset out_libref to the backup value */
62 %let out_libref = &out_libref_tmp.;
63
64%do i=1 %to &n_keys;
65 proc sql noprint;
66 create table agg as
67 select *
68 from work.ds_out_agg_rules_config
69 where tgt_table_schema_nm ="&&planning_data_&i.."
70 ;
71 quit;
72
73 /* Get the variables in the configuration tbl and if they are not in the trgt tbl create them */
74 /* initiate the columns in target tbl */
75 %let tgt_cols=;
76 proc sql;
77 select distinct tgt_tbl_val_col
78 into: tgt_cols separated by ' '
79 from agg;
80 quit;
81 %do m=1 %to %sysfunc(countw(&tgt_cols.," "));
82 %let var_exist=%rsk_varexist(&&planning_data_&i.., %scan(&tgt_cols.,&m.," "));
83 %if &var_exist.=0 %then %do;
84 proc sql;
85 alter table work.&&planning_data_&i.. add %scan(&tgt_cols.,&m.," ") num(8);
86 quit;
87 %end;
88 %end;
89 data &out_libref..&&planning_data_&i..;
90 set work.&&planning_data_&i..;
91 run;
92
93%end;
94
95data &ds_out_info_tbl.;
96done='done';
97run;
98%mend;