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. display_value should always be character, raw_value is unformatted
16  character/numeric.
17 
18  <h5>DYNAMIC_VALUES</h5>
19  The RAW_VALUE column may be charactor or numeric. If DISPLAY_INDEX is not
20  provided, it is added automatically.
21 
22  |DISPLAY_INDEX:best.|DISPLAY_VALUE:$|RAW_VALUE|
23  |---|---|---|
24  |1|$77.43|77.43|
25  |2|$88.43|88.43|
26 
27  <h5>DYNAMIC_EXTENDED_VALUES</h5>
28  This table is optional. If provided, it will map the DISPLAY_INDEX from the
29  DYNAMIC_VALUES table to additional column/value pairs, that will be used to
30  populate dropdowns for _other_ cells in the _same_ row.
31 
32  Should be used sparingly! The use of large tables here can slow down the
33  browser.
34 
35  The FORCED_VALUE column can be used to force an extended value to be selected
36  by default when a particular value is chosen.
37 
38  |DISPLAY_INDEX:best.|EXTRA_COL_NAME:$32.|DISPLAY_VALUE:$|DISPLAY_TYPE:$1.|RAW_VALUE_NUM|RAW_VALUE_CHAR:$5000|FORCED_VALUE|
39  |---|---|---|---|
40  |1|DISCOUNT_RT|"50%"|N|0.5||.|
41  |1|DISCOUNT_RT|"40%"|N|0.4||0|
42  |1|DISCOUNT_RT|"30%"|N|0.3||1|
43  |1|CURRENCY_SYMBOL|"GBP"|C||"GBP"|.|
44  |1|CURRENCY_SYMBOL|"RSD"|C||"RSD"|.|
45  |2|DISCOUNT_RT|"50%"|N|0.5||.|
46  |2|DISCOUNT_RT|"40%"|N|0.4||1|
47  |2|CURRENCY_SYMBOL|"EUR"|C||"EUR"|.|
48  |2|CURRENCY_SYMBOL|"HKD"|C||"HKD"|1|
49 
50  <h4> SAS Macros </h4>
51  @li dc_getlibs.sas
52 
53 
54 **/
55 
56 %mp_abort(iftrue= ("%upcase(&libds)" ne "&DC_LIBREF..MPE_ALERTS" )
57  ,mac=&_program
58  ,msg=%str(
59  Invalid validation, expected MPE_ALERTS.ALERT_LIB, got %superq(libds)
60  )
61 )
62 
63 proc sql;
64 create table work.source as
65  select libref,dsn
66  from &DC_LIBREF..MPE_TABLES
67  where tx_to > &dc_dttmtfmt.
68  order by 1,2;
69 
70 data work.DYNAMIC_VALUES (keep=display_index raw_value display_value);
71  set work.source end=last;
72  by libref;
73  if last.libref then do;
74  display_index+1;
75  raw_value=libref;
76  display_value=libref;
77  output;
78  end;
79  if last then do;
80  display_index+1;
81  raw_value='*ALL*';
82  display_value='*ALL*';
83  output;
84  end;
85 run;
86 
87 
88 data work.dynamic_extended_values(keep=display_index extra_col_name display_type
89  display_value RAW_VALUE_CHAR raw_value_num forced_value);
90  set work.source end=last;
91  by libref dsn;
92  retain extra_col_name 'ALERT_DS';
93  retain display_type 'C';
94  retain raw_value_num .;
95  raw_value_char=dsn;
96  display_value=dsn;
97  forced_value=0;
98 
99  if first.libref then display_index+1;
100  if last.libref then do;
101  display_value='*ALL*';
102  raw_value_char='*ALL*';
103  forced_value=1;
104  output;
105  end;
106  else output;
107 
108 run;