Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mddl_derivedvars.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief DDL for the derived variables control table
4 @details Creates the table read by mp_derivedvars.sas. One row defines one
5 derived variable for one target table.
6
7 Usage:
8
9 %mddl_derivedvars(libds=perm.derived_vars)
10
11 <h4> Related Macros </h4>
12 @li mp_derivedvars.sas
13
14 @param [in] libds= (work.derived_vars) The table to create. The libref must
15 be assigned, and the table must not already exist.
16
17 @version 5.6
18 @author 4GL Apps Ltd
19
20**/
21
22%macro mddl_derivedvars(libds=work.derived_vars);
23
24 %local lib;
25 %let libds=%upcase(&libds);
26 %if %index(&libds,.)=0 %then %let lib=WORK;
27 %else %let lib=%scan(&libds,1,.);
28
29 proc sql;
30 create table &libds(
31 libref char(8) label='Library Reference (8 chars)',
32 dsn char(32) label='Dataset Name (32 chars)',
33 var_nm char(32) label='Name of the derived variable',
34 var_deps char(4000) label='Columns and derived variables this uses',
35 var_type char(1) label='Either (C)haracter or (N)umeric',
36 var_len num label='Length of the derived variable',
37 var_fmt char(32) label='SAS format, eg DATE9.',
38 var_label char(256) label='Optional label; defaults to NAME=expression',
39 var_logic char(4000) label='SAS expression that produces the value',
40 active num label='Is the variable active? (1/0)'
41 );
42 quit;
43
44 proc datasets lib=&lib noprint;
45 modify %scan(&libds,-1,.);
46 index create
47 pk_derivedvars=(libref dsn var_nm)
48 /nomiss unique;
49 quit;
50
51%mend mddl_derivedvars;