Macros for SAS Application Developers
https://github.com/sasjs/core
mp_cntlout.sas
Go to the documentation of this file.
1/**
2 @file mp_cntlout.sas
3 @brief Creates a cntlout dataset in a consistent format
4 @details The dataset produced by proc format in the cntlout option will vary
5 according to its contents.
6
7 When dealing with formats from an ETL perspective (eg in [Data Controller for
8 SAS](https://datacontroller.io)), it is important that the output dataset
9 has a consistent model (and compariable values).
10
11 This macro makes use of mddl_sas_cntlout.sas to provide the consistent model,
12 and will left-align the start and end values when dealing with numeric ranges
13 to enable consistency when checking for differences.
14
15 usage:
16
17 %mp_cntlout(libcat=yourlib.cat,cntlout=work.formatexport)
18
19 @param [in] libcat The library.catalog reference
20 @param [in] fmtlist= (0) provide a space separated list of specific formats to
21 extract
22 @param [in] iftrue= (1=1) A condition under which the macro should be executed
23 @param [out] cntlout= (work.fmtextract) Libds reference for the output dataset
24
25 <h4> SAS Macros </h4>
26 @li mddl_sas_cntlout.sas
27 @li mf_getuniquename.sas
28
29 <h4> Related Macros </h4>
30 @li mf_getvarformat.sas
31 @li mp_getformats.sas
32 @li mp_loadformat.sas
33 @li mp_ds2fmtds.sas
34
35 @version 9.2
36 @author Allan Bowe
37 @cond
38**/
39
40%macro mp_cntlout(
41 iftrue=(1=1)
42 ,libcat=
43 ,cntlout=work.fmtextract
44 ,fmtlist=0
45)/*/STORE SOURCE*/;
46%local ddlds cntlds i;
47
48%if not(%eval(%unquote(&iftrue))) %then %return;
49
50%let ddlds=%mf_getuniquename();
51%let cntlds=%mf_getuniquename();
52
53%mddl_sas_cntlout(libds=&ddlds)
54
55%if %index(&libcat,-)>0 and %scan(&libcat,2,-)=FC %then %do;
56 %let libcat=%scan(&libcat,1,-);
57%end;
58
59proc format lib=&libcat cntlout=&cntlds;
60%if "&fmtlist" ne "0" %then %do;
61 select
62 %do i=1 %to %sysfunc(countw(&fmtlist));
63 %scan(&fmtlist,&i,%str( ))
64 %end;
65 ;
66%end;
67run;
68
69data &cntlout;
70 if 0 then set &ddlds;
71 set &cntlds;
72 if type="N" then do;
73 start=cats(start);
74 end=cats(end);
75 end;
76run;
77proc sort;
78 by fmtname start;
79run;
80
81proc sql;
82drop table &ddlds,&cntlds;
83
84%mend mp_cntlout;
85/** @endcond */