Loading...
Searching...
No Matches
getcols.sas
Go to the documentation of this file.
1/**
2 @file getcols.sas
3 @brief Retrieves column info to enable population of dropdowns
4 @details
5
6 <h4> SAS Macros </h4>
7 @li dc_assignlib.sas
8 @li mp_abort.sas
9 @li mp_getcols.sas
10 @li mp_validatecol.sas
11
12 @version 9.2
13 @author 4GL Apps Ltd
14 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
15 and may not be re-distributed or re-sold without the express permission of
16 4GL Apps Ltd.
17
18**/
19%mpeinit()
20
21
22/**
23 * The libds is read from the IWANT input table. Reading it with
24 * mf_getvalue would re-resolve any macro content in the value, so it is
25 * read with symget in a data step and validated (LIBREF.DATASET) before
26 * it is used in proc contents.
27 */
28%let is_libds=0;
29data _null_;
30 length _libds $64;
31 set work.iwant;
32 _libds=libds;
33 %mp_validatecol(_libds,LIBDS,is_libds)
34 if is_libds=0 then putlog 'ERR' 'OR: Invalid libds:' _libds;
35 call symputx('is_libds',is_libds,'l');
36 if is_libds=1 then call symputx('ds',upcase(_libds),'l');
37 stop;
38run;
39
40%mp_abort(iftrue= (&is_libds ne 1)
41 ,mac=&_program..sas
42 ,msg=%str(Invalid libds)
43)
44
45%dc_assignlib(READ,%scan(&ds,1,.))
46
47/* Column metadata, typed the way the editor's own load types it: %mp_getcols
48 infers DATE and DATETIME across the whole format list (YYMMDD, MMDDYY,
49 E8601DA, B8601DA, NLDATE, NLDATM, E8601DT, ...), which a test against the
50 format prefix does not - a column formatted YYMMDD would otherwise reach the
51 picker as numeric. getdata.sas makes the same call for the same reason. */
52%mp_getcols(&ds, outds=cols1)
53
54/* Response contract. `type` keeps the SAS vocabulary this public service has
55 always used (C/N), and `format` and `label` are carried over from the
56 previous shape, so an existing caller still finds them unchanged. `fmtname`
57 (the bare format name) and `ddtype` (which now distinguishes DATE, DATETIME
58 and TIME) are additions. The client derives its own num/char vocabulary from
59 ddtype at the store boundary - see sas-store.getCols. */
60data cols(keep=name type length varnum fmtname format label ddtype);
61 set cols1;
62 /* DDTYPE in the client's vocabulary, as getdata.sas maps it. ddtype needs
63 no length statement - the macro creates it with 'CHARACTER', so it is
64 already $9. */
65 if ddtype='CHARACTER' then ddtype='C';
66 else if ddtype='NUMERIC' then ddtype='N';
67run;
68
69%mp_abort(iftrue= (&syscc ne 0)
70 ,mac=&_program..sas
71 ,msg=%str(syscc=&syscc)
72)
73
74%webout(OPEN)
75%webout(OBJ,cols)
76%webout(CLOSE)
77
78
79%mpeterm()