Loading...
Searching...
No Matches
mpe_alerts.alert_lib.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief fetch extended values for alert_lib
4 @details Fetches libraries from mpe_tables, creates extended values for
5 alert_ds, and marks "*ALL*" as the forced (default) value.
6
7 Available macro variables:
8 @li DC_LIBREF - The DC control library
9 @li LIBDS - The library.dataset being filtered
10 @li VARIABLE_NM - The column being filtered
11
12
13 <h4> Service Outputs </h4>
14 Output should be a single table called "work.dynamic_values" in the format
15 below. raw_value is unformatted haracter/numeric.
16
17 <h5>DYNAMIC_VALUES</h5>
18 The RAW_VALUE column may be charactor or numeric. If DISPLAY_INDEX is not
19 provided, it is added automatically.
20
21 |DISPLAY_INDEX:best.|RAW_VALUE|
22 |---|---|
23 |1|77.43|
24 |2|88.43|
25
26 <h5>DYNAMIC_EXTENDED_VALUES</h5>
27 This table is optional. If provided, it will map the DISPLAY_INDEX from the
28 DYNAMIC_VALUES table to additional column/value pairs, that will be used to
29 populate dropdowns for _other_ cells in the _same_ row.
30
31 Should be used sparingly! The use of large tables here can slow down the
32 browser.
33
34 The FORCED_VALUE column can be used to force an extended value to be selected
35 by default when a particular value is chosen.
36
37 |DISPLAY_INDEX:best.|EXTRA_COL_NAME:$32.|DISPLAY_TYPE:$1.|RAW_VALUE_NUM|RAW_VALUE_CHAR:$5000|FORCED_VALUE|
38 |---|---|---|---|---|---|
39 |1|DISCOUNT_RT|N|0.5||.|
40 |1|DISCOUNT_RT|N|0.4||0|
41 |1|DISCOUNT_RT|N|0.3||1|
42 |1|CURRENCY_SYMBOL|C||"GBP"|.|
43 |1|CURRENCY_SYMBOL|C||"RSD"|.|
44 |2|DISCOUNT_RT|N|0.5||.|
45 |2|DISCOUNT_RT|N|0.4||1|
46 |2|CURRENCY_SYMBOL|C||"EUR"|.|
47 |2|CURRENCY_SYMBOL|C||"HKD"|1|
48
49 <h4> SAS Macros </h4>
50 @li dc_getlibs.sas
51
52
53**/
54
55%mp_abort(iftrue= ("%upcase(&libds)" ne "&DC_LIBREF..MPE_ALERTS" )
56 ,mac=&_program
57 ,msg=%str(
58 Invalid validation, expected MPE_ALERTS.ALERT_LIB, got %superq(libds)
59 )
60)
61
62proc sql;
63create table work.source as
64 select libref,dsn
65 from &DC_LIBREF..MPE_TABLES
66 where tx_to > &dc_dttmtfmt.
67 order by 1,2;
68
69data work.DYNAMIC_VALUES (keep=display_index raw_value );
70 set work.source end=last;
71 by libref;
72 if last.libref then do;
73 display_index+1;
74 raw_value=libref;
75 output;
76 end;
77 if last then do;
78 display_index+1;
79 raw_value='*ALL*';
80 output;
81 end;
82run;
83
84
85data work.dynamic_extended_values(keep=display_index extra_col_name display_type
86 RAW_VALUE_CHAR raw_value_num forced_value);
87 set work.source end=last;
88 by libref dsn;
89 retain extra_col_name 'ALERT_DS';
90 retain display_type 'C';
91 retain raw_value_num .;
92 raw_value_char=dsn;
93 forced_value=0;
94
95 if first.libref then display_index+1;
96 if last.libref then do;
97 raw_value_char='*ALL*';
98 forced_value=1;
99 output;
100 end;
101 else output;
102
103run;