Published on :
Macro INTERNE

Generating DDL for a SAS table

This code is also available in: Deutsch Español Français
The `%mp_ds2ddl` macro acts as a simplified interface for the more generic `%mp_getddl` macro. It takes a complete library and dataset reference (`libds`) as input, then extracts the library and dataset name. A verification mechanism is in place to default to the `WORK` library if no library is explicitly provided in the `libds` parameter. All other parameters (`fref`, `flavour`, `showlog`, `schema`, `applydttm`) are directly passed to the underlying `%mp_getddl` macro, which is effectively responsible for the DDL generation logic.
Data Analysis

Type : INTERNE


The macro operates on an existing SAS table specified by the `libds` parameter. It does not introduce new data or read external files not managed by the script itself. Data is assumed to be already available in the SAS environment when the macro is called.

1 Code Block
MACRO MP_DS2DDL
Explanation :
This block defines the `%mp_ds2ddl` macro. It starts by declaring a local `libref` variable. It then converts the `libds` parameter value to uppercase. The macro extracts the 'libref' part from `libds`. If `libds` contains only a table name (no library specified), it prefixes `WORK.` to form a complete reference. Finally, it calls the `%mp_getddl` macro, passing it the extracted library and table name, as well as all other received parameters.
Copied!
1%macro mp_ds2ddl(libds,fref=getddl,flavour=SAS,showlog=YES,schema=
2 ,applydttm=NO
3)/*/STORE SOURCE*/;
4 
5%local libref;
6%let libds=%upcase(&libds);
7%let libref=%scan(&libds,1,.);
8%IF &libref=&libds %THEN %let libds=WORK.&libds;
9 
10%mp_getddl(%scan(&libds,1,.)
11 ,%scan(&libds,2,.)
12 ,fref=&fref
13 ,flavour=SAS
14 ,showlog=&showlog
15 ,schema=&schema
16 ,applydttm=&applydttm
17)
18 
19%mend mp_ds2ddl;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright 2010-2023 HMS Analytical Software GmbH, http://www.analytical-software.de