columns_in_libds.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Generic validator for table columns
4  @details The input table is simply one row from the target table in table
5  called "work.source_row".
6 
7  Available macro variables:
8  @li MPELIB - The DC control library
9  @li LIBDS - The library.dataset being filtered
10  @li VARIABLE_NM - The column being filtered
11 
12  <h4> Service Inputs </h4>
13  <h5> work.sourcerow </h5>
14  Has source table structure.
15 
16  <h4> Service Outputs </h4>
17 
18  The values provided below are generic samples - we encourage you to replace
19  these with realistic values in your own deployments.
20 
21  <h5>DYNAMIC_VALUES</h5>
22  The RAW_VALUE column may be charactor or numeric. If DISPLAY_INDEX is not
23  provided, it is added automatically.
24 
25  |DISPLAY_INDEX:best.|DISPLAY_VALUE:$|RAW_VALUE|
26  |---|---|---|
27  |1|$77.43|77.43|
28  |2|$88.43|88.43|
29 
30  <h5>DYNAMIC_EXTENDED_VALUES</h5>
31  This table is optional. If provided, it will map the DISPLAY_INDEX from the
32  DYNAMIC_VALUES table to additional column/value pairs, that will be used to
33  populate dropdowns for _other_ cells in the _same_ row.
34 
35  Should be used sparingly! The use of large tables here can slow down the
36  browser.
37 
38  |DISPLAY_INDEX:best.|EXTRA_COL_NAME:$32.|DISPLAY_VALUE:$|DISPLAY_TYPE:$1.|RAW_VALUE_NUM|RAW_VALUE_CHAR:$5000|
39  |---|---|---|
40  |1|DISCOUNT_RT|"50%"|N|0.5||
41  |1|DISCOUNT_RT|"40%"|N|0.4||
42  |1|DISCOUNT_RT|"30%"|N|0.3||
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||
47  |2|CURRENCY_SYMBOL|"EUR"|C||"EUR"|
48  |2|CURRENCY_SYMBOL|"HKD"|C||"HKD"|
49 
50  <h4> SAS Macros </h4>
51  @li dc_assignlib.sas
52  @li mf_getuniquename.sas
53  @li mp_abort.sas
54  @li mp_validatecol.sas
55 
56 
57 **/
58 
59 /* send back the raw and formatted values */
60 %let tgtlibds=0;
61 %let varlibds=%mf_getuniquename();
62 %let vartgtlibds=%mf_getuniquename();
63 %let var_is_libds=%mf_getuniquename();
64 
65 data _null_;
66  length xl_libref base_lib select_lib rls_libref cls_libref libref $8
67  xl_table base_ds select_ds rls_table cls_table dsn $32;
68  if _n_=1 then call missing(of _all_);
69  set work.source_row;
70  &varlibds=symget('libds');
71  if &varlibds="&mpelib..MPE_EXCEL_CONFIG"
72  then &vartgtlibds=cats(xl_libref,'.',xl_table);
73  else if &varlibds="&mpelib..MPE_VALIDATIONS"
74  then &vartgtlibds=cats(BASE_LIB,'.',BASE_DS);
75  else if &varlibds="&mpelib..MPE_SELECTBOX"
76  then &vartgtlibds=cats(select_lib,'.',select_ds);
77  else if &varlibds="&mpelib..MPE_ROW_LEVEL_SECURITY"
78  then &vartgtlibds=cats(RLS_LIBREF,'.',RLS_TABLE);
79  else if &varlibds="&mpelib..MPE_COLUMN_LEVEL_SECURITY"
80  then &vartgtlibds=cats(CLS_LIBREF,'.',CLS_TABLE);
81  else if &varlibds="&mpelib..MPE_TABLES"
82  then &vartgtlibds=cats(LIBREF,'.',DSN);
83 
84  /* validate libds */
85  %mp_validatecol(&vartgtlibds,LIBDS,&var_is_libds)
86 
87  if &var_is_libds=1 then call symputx('tgtlibds',&vartgtlibds);
88  putlog (_all_)(=);
89 run;
90 
91 %mp_abort(iftrue= ("&tgtlibds" ="0" )
92  ,mac=&_program..sas
93  ,msg=%str(Unable to extract libds vars from &libds inputs for &variable_nm)
94 )
95 
96 %dc_assignlib(READ,%scan(&tgtlibds,1,.))
97 
98 proc contents noprint data=&tgtlibds
99  out=work.DYNAMIC_VALUES (keep=name rename=(name=display_value) );
100 run;
101 
102 data work.DYNAMIC_VALUES;
103  set work.DYNAMIC_VALUES;
104  raw_value=upcase(display_value);
105  format raw_value;
106 run;
107 
108