Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
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 @li mp_aligndecimal.sas
29
30 <h4> Related Macros </h4>
31 @li mf_getvarformat.sas
32 @li mp_getformats.sas
33 @li mp_loadformat.sas
34 @li mp_ds2fmtds.sas
35
36 @version 9.2
37 @author Allan Bowe
38 @cond
39**/
40
41%macro mp_cntlout(
42 iftrue=(1=1)
43 ,libcat=
44 ,cntlout=work.fmtextract
45 ,fmtlist=0
46)/*/STORE SOURCE*/;
47%local ddlds cntlds i;
48
49%if not(%eval(%unquote(&iftrue))) %then %return;
50
51%let ddlds=%mf_getuniquename();
52%let cntlds=%mf_getuniquename();
53
54%mddl_sas_cntlout(libds=&ddlds)
55
56%if %index(&libcat,-)>0 and %scan(&libcat,2,-)=FC %then %do;
57 %let libcat=%scan(&libcat,1,-);
58%end;
59
60proc format lib=&libcat cntlout=&cntlds;
61%if "&fmtlist" ne "0" and "&fmtlist" ne "" %then %do;
62 select
63 %do i=1 %to %sysfunc(countw(&fmtlist,%str( )));
64 %scan(&fmtlist,&i,%str( ))
65 %end;
66 ;
67%end;
68run;
69
70data &cntlout/nonote2err;
71 if 0 then set &ddlds;
72 set &cntlds;
73 by type fmtname notsorted;
74
75 /* align the numeric values to avoid overlapping ranges */
76 if type in ("I","N") then do;
77 %mp_aligndecimal(start,width=16)
78 %mp_aligndecimal(end,width=16)
79 end;
80
81 /* create row marker. Data cannot be sorted without it! */
82 if first.fmtname then fmtrow=1;
83 else fmtrow+1;
84
85run;
86proc sort;
87 by type fmtname fmtrow;
88run;
89
90proc sql;
91drop table &ddlds,&cntlds;
92
93%mend mp_cntlout;
94/** @endcond */