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_validatecol.sas
10
11 @version 9.2
12 @author 4GL Apps Ltd
13 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
14 and may not be re-distributed or re-sold without the express permission of
15 4GL Apps Ltd.
16
17**/
18%mpeinit()
19
20
21/**
22 * The libds is read from the IWANT input table. Reading it with
23 * mf_getvalue would re-resolve any macro content in the value, so it is
24 * read with symget in a data step and validated (LIBREF.DATASET) before
25 * it is used in proc contents.
26 */
27%let is_libds=0;
28data _null_;
29 length _libds $64;
30 set work.iwant;
31 _libds=libds;
32 %mp_validatecol(_libds,LIBDS,is_libds)
33 if is_libds=0 then putlog 'ERR' 'OR: Invalid libds:' _libds;
34 call symputx('is_libds',is_libds,'l');
35 if is_libds=1 then call symputx('ds',upcase(_libds),'l');
36 stop;
37run;
38
39%mp_abort(iftrue= (&is_libds ne 1)
40 ,mac=&_program..sas
41 ,msg=%str(Invalid libds)
42)
43
44%dc_assignlib(READ,%scan(&ds,1,.))
45
46proc contents noprint data=&ds
47 out=droplist1 (keep=name type length label varnum format:);
48run;
49data cols(keep=name type length varnum format label);
50 set droplist1(rename=(format=format2 type=type2));
51 name=upcase(name);
52 if type2=2 then do;
53 length format $49.;
54 if format2='' then format=cats('$',length,'.');
55 else if formatl=0 then format=cats(format2,'.');
56 else format=cats(format2,formatl,'.');
57 type='C';
58 ddtype='C';
59 end;
60 else do;
61 if format2='' then format=cats(length,'.');
62 else if formatl=0 then format=cats(format2,'.');
63 else if formatd=0 then format=cats(format2,formatl,'.');
64 else format=cats(format2,formatl,'.',formatd);
65 type='N';
66 if format=:'DATETIME' then ddtype='DATETIME';
67 else if format=:'DATE' then ddtype='DATE';
68 else if format=:'TIME' then ddtype='TIME';
69 else ddtype='N';
70 end;
71 if label='' then label=name;
72run;
73
74%mp_abort(iftrue= (&syscc ne 0)
75 ,mac=&_program..sas
76 ,msg=%str(syscc=&syscc)
77)
78
79%webout(OPEN)
80%webout(OBJ,cols)
81%webout(CLOSE)
82
83
84%mpeterm()