Loading...
Searching...
No Matches
getddl.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Download DDL for a table or entire library in a particular flavour.
4 @details
5
6 <h4> SAS Macros </h4>
7 @li mddl_sas_cntlout.sas
8 @li dc_assignlib.sas
9 @li mf_existds.sas
10 @li mp_abort.sas
11 @li mp_getddl.sas
12 @li mp_streamfile.sas
13
14
15 @version 9.2
16 @author 4GL Apps Ltd
17 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
18 and may not be re-distributed or re-sold without the express permission of
19 4GL Apps Ltd.
20**/
21%global libref ds flavour;
22
23%let flavour=%sysfunc(coalescec(&flavour,SAS));
24
25%mpeinit()
26
27%dc_assignlib(READ,&libref)
28
29data _null_;
30 /* check if the request is for a format catalog */
31 ds=symget('ds');
32 if subpad(cats(reverse(ds)),1,3)=:'CF-' then do;
33 ds=scan(ds,1,'-');
34 libds=cats(symget('libref'),'.',ds);
35 putlog "Format Catalog Captured";
36 call execute('%mddl_sas_cntlout(libds=work.fmtextract)');
37 call symputx('libref','work');
38 call symputx('ds','fmtextract');
39 end;
40 putlog (_all_)(=);
41run;
42
43%mp_abort(iftrue=("exist&ds" ne "exist" and %mf_existds(libds=&libref..&ds)<1)
44 ,mac=&_program
45 ,msg=%str(Dataset &libref..&ds was not found)
46)
47
48%let tmploc=%sysfunc(pathname(work))/temp.txt;
49filename tmp "&tmploc";
50%mp_getddl(&libref,&ds,flavour=&flavour, fref=tmp, applydttm=YES)
51
52%mp_streamfile(contenttype=TEXT
53 ,inloc=%str(&tmploc)
54 ,outname=&libref._&ds..ddl
55)