Loading...
Searching...
No Matches
mpe_tables.dsn.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief fetch extended values for DSN
4 @details Fetches datasets in a library, and ALSO fetches a list of numeric
5 vars for each dataset for use in adjacent columns (such as VAR_PROCESSED,
6 TX_TO etc).
7
8 Available macro variables:
9 @li MPELIB - The DC control library
10 @li LIBDS - The library.dataset being filtered
11 @li VARIABLE_NM - The column being filtered
12
13
14 <h4> Service Outputs </h4>
15 Output should be a single table called "work.dynamic_values" in the format
16 below.
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.|RAW_VALUE|
23 |---|---|
24 |1|77.43|
25 |2|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|EXTRA_COL_NAME:$32.|DISPLAY_TYPE:$1.|RAW_VALUE_NUM|RAW_VALUE_CHAR:$5000|
39 |---|---|---|---|---|
40 |1|DISCOUNT_RT|N|0.5||
41 |1|DISCOUNT_RT|N|0.4||
42 |1|DISCOUNT_RT|N|0.3||
43 |1|CURRENCY_SYMBOL|C||"GBP"|
44 |1|CURRENCY_SYMBOL|C||"RSD"|
45 |2|DISCOUNT_RT|N|0.5||
46 |2|DISCOUNT_RT|N|0.4||
47 |2|CURRENCY_SYMBOL|C||"EUR"|
48 |2|CURRENCY_SYMBOL|C||"HKD"|
49
50 <h4> SAS Macros </h4>
51 @li dc_assignlib.sas
52 @li mf_getuniquename.sas
53 @li mp_abort.sas
54
55 @sasjslint {"maxLineLength": 89}
56
57**/
58
59
60/* send back the raw and formatted values */
61%let tgtlib=0;
62%let varlibds=%mf_getuniquename();
63%let vartgtlib=%mf_getuniquename();
64%let var_is_lib=%mf_getuniquename();
65data _null_;
66 length &varlibds $41 &vartgtlib $8;
67 set work.source_row;
68 &varlibds=upcase(symget('libds'));
69 if &varlibds="&mpelib..MPE_TABLES" then &vartgtlib=LIBREF;
70 else putlog "something unexpected happened";
71
72 /* validate name */
73 if nvalid(&vartgtlib,'v7') then call symputx('tgtlib',&vartgtlib);
74 call symputx('vartgtlib',&vartgtlib);
75
76 putlog (_all_)(=);
77run;
78
79%mp_abort(iftrue= ("&tgtlib" ="0" )
80 ,mac=&_program..sas
81 ,msg=%str(Invalid library - %superq(vartgtlib))
82 ,errds=work.dc_error_response
83)
84
85%dc_assignlib(READ,&tgtlib)
86
87
88proc sql;
89create table work.source as
90 select upcase(memname) as memname
91 ,upcase(name) as name
92 ,type
93 from dictionary.columns
94 where libname="&TGTLIB"
95 and memtype='DATA';
96
97create table work.members as
98 select distinct upcase(memname) as raw_value
99 from work.source;
100
101data work.DYNAMIC_VALUES;
102 set work.members;
103 display_index=_n_;
104run;
105
106proc sql;
107create table work.dynamic_extended_values as
108 select a.display_index
109 ,a.raw_value
110 ,"C" as display_type
111 ,b.name as RAW_VALUE_CHAR
112 ,. as RAW_VALUE_NUM
113 from work.dynamic_values a
114 left join work.source b
115 on a.raw_value=b.memname
116 where b.type='num';
117
118data work.dynamic_extended_values;
119 set work.DYNAMIC_EXTENDED_VALUES;
120 extra_col_name='VAR_PROCESSED';output;
121 extra_col_name='VAR_TXFROM';output;
122 extra_col_name='VAR_TXTO';output;
123 extra_col_name='VAR_BUSFROM';output;
124 extra_col_name='VAR_BUSTO';output;
125run;
126/* set some force flags */
127data work.dynamic_extended_values;
128 set work.DYNAMIC_EXTENDED_VALUES;
129 forced_value=0;
130 if extra_col_name='VAR_TXFROM' & raw_value_char='TX_FROM' then forced_value=1;
131 if extra_col_name='VAR_TXTO' & raw_value_char='TX_TO' then forced_value=1;
132run;
133
134proc sort;
135 by extra_col_name display_index;
136run;