1 /*
2
3 - - - - - - - - - - - - - - - - - - - - - -
4
5 SAS_ODS_DDI3_Tagset_run.sas
6
7 SAS command setup for using the SAS ODS DDI3 Tagset
8 Usage see comments.
9
10 - - - - - - - - - - - - - - - - - - - - - -
11
12 $HeadURL: http://db2/svn/ddi/StatsProgs2DDI/SAS/SAS_ODS_DDI_Tagset_run.sas $
13 $LastChangedDate: 2008-03-18 16:32:40 +0100 (Di, 18 Mrz 2008) $
14 $LastChangedRevision: 156 $
15 $LastChangedBy: wackerow $
16
17 - - - - - - - - - - - - - - - - - - - - - -
18
19 */
20
21 libname library 'E:\DDI\SAS\Tagset\' ; /* with quotes */
22 %let sas_file_basename = za3950_f ; /* without quotes */
23
24 /*
25 * Creates a SAS data set (_formats) that stores information about informats and formats that are
26 * contained in the catalog specified in the LIBRARY= option.
27 */
28 proc format
29 lib = library
30 cntlout = _formats(
31 keep = fmtname type start end label
32 rename = ( fmtname = format )
33 where = (type = 'N' or type = 'C' )
34 ) ;
35 run ;
36
37 /*
38 * Creates a SAS data set (_contents) that stores information about the contents of a SAS data set.
39 */
40 proc contents
41 data=library.&sas_file_basename
42 out=_contents(
43 keep = name label format type length
44 /* where = (name eq 'V4' or name eq 'V5') */ /* only some variables for test purposes */
45 where = (format ne ' ' ) /* exclude variables without user-defined format */
46 )
47 noprint ;
48 run ;
49
50 /*
51 * Joins _formats and _contents to _used_formats.
52 * Keeps only the user-defined formats, which are used by the variables of this dataset.
53 */
54 proc sql ;
55 create table _used_formats as
56 select _formats.*
57 from _contents left join _formats
58 on _contents.format = _formats.format
59 order by _formats.format, _formats.start
60 ;
61 quit ;
62
63 /* output as SAS default XML, useful for debugging purposes */
64 /* ods tagsets.Default encoding='utf-8' file='E:\DDI\SAS\Tagset\all_default.xml' ; */
65 /* output in PDF format */
66 /* ods PDF file = 'E:\DDI\SAS\Tagset\all.pdf' ; */
67 /* output in DDI format */
68 ods tagsets.DDI encoding='utf-8' file='E:\DDI\SAS\Tagset\all_ddi.xml' ;
69 ods listing close; /* supress default output */
70 /* ods trace on; */ /* for debugging */
71
72 /* IMPORTANT: The following numbered statements must stay in this sequence.
73
74 /* 1.
75 * Title of the study.
76 *
77 * DDI: Citation title in study unit.
78 *
79 * This statement can be omitted if title should be used.
80 */
81 title 'Example Study' ;
82
83 /* 2.
84 * Shows the contents of a SAS data set.
85 *
86 * DDI: Basis for variable scheme.
87 */
88 proc contents data = library.&sas_file_basename ;
89 run ;
90
91 /* 3.
92 * Prints user-defined formats grouped by format name.
93 * Setting the contents parameter to 'User-defined Formats' is mandatory.
94 *
95 * DDI: Basis for category and coding scheme.
96 *
97 * This proc statement can be omitted if no user-defined formats should be converted.
98 */
99 proc print data=_used_formats contents='User-defined Formats' ;
100 by format ;
101 run;
102
103 /* ods tagsets.Default close; */
104 /* ods PDF close; */
105 ods tagsets.DDI close ;
106 ods listing; /* set listing to default */
107 /* ods trace off; */
syntax highlighted by Code2HTML, v. 0.9.1