Loading...
Searching...
No Matches
mpe_validations_postedit.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Post Edit Hook script for the MPE_VALIDATIONS table
4 @details Post edit hooks provide additional backend validation for user
5 provided data. The incoming dataset is named `work.staging_ds` and is
6 provided in mpe_loader.sas.
7
8 Available macro variables:
9 @li DC_LIBREF - The DC control library
10 @li LIBREF - The library of the dataset being edited (is assigned)
11 @li DS - The dataset being edited
12
13 This validation checks the incoming mpe_validations settings to ensure
14 there are no columns that have both HARDSELECT_HOOK and SOFTSELECT_HOOK.
15
16 <h4> SAS Macros </h4>
17 @li mf_nobs.sas
18
19 <h4> Related Macros </h4>
20 @li mpe_loader.sas
21
22**/
23
24
25/** check to avoid a colum having both HARDSELECT_HOOK and SOFTSELECT_HOOK */
26/* need to merge with base table in the case of a single row being added */
27%global src_list1 src_list2;
28%let src_list1='';
29proc sql noprint;
30create table work.check1 as
31 select quote(catx('.',base_lib,base_ds,base_col)) as source
32 ,rule_type
33 from work.staging_ds
34 where rule_type in ('SOFTSELECT_HOOK','HARDSELECT_HOOK')
35 and upcase(_____DELETE__THIS__RECORD_____) ne "YES";
36
37select distinct cats(source) into: src_list1 separated by ','
38 from work.check1;
39
40create table work.check2 as
41 select quote(catx('.',base_lib,base_ds,base_col)) as source
42 ,rule_type
43 from &DC_LIBREF..MPE_VALIDATIONS
44 where rule_type in ('SOFTSELECT_HOOK','HARDSELECT_HOOK')
45 and &dc_dttmtfmt. lt tx_to
46 and catx('.',base_lib,base_ds,base_col) in (&src_list1);
47
48create table work.check3 as
49 select * from work.check1
50union
51 select * from work.check2;
52
53create table work.validation_checker as
54 select source
55 ,count(*) as cnt
56 from work.check3
57 group by 1
58 having cnt>1;
59
60select distinct source into: src_list2 from work.validation_checker;
61
62data _null_;
63 set work.validation_checker;
64 putlog (_all_)(=);
65run;
66
67
68%mp_abort(iftrue= (%mf_nobs(work.validation_checker)>0)
69 ,mac=mpe_validations_postedit
70 ,msg=%str(The following vars have duplicate HOOKS: &src_list2)
71)
72