forked from ptatian/uiautos
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFile_info.sas
More file actions
100 lines (67 loc) · 2.54 KB
/
Copy pathFile_info.sas
File metadata and controls
100 lines (67 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/******************* URBAN INSTITUTE MACRO LIBRARY *********************
Macro: File_info
Description: Autocall macro to print basic information for a
data set: contents, first few obs., and descriptive statistics.
Use: Open code
Author: Peter Tatian
***********************************************************************/
%macro File_info(
data=, /* Data set */
contents=Y, /* Print Proc Contents (N to suppress) */
printobs=10, /* Number of obs. to print (0 to suppress) */
printchar=N, /* Print char. vars. only when printing obs. */
printvars=, /* List of variables to print (optional) */
freqvars=, /* List of variables for frequency tables (optional) */
stats=n sum mean stddev min max /* Proc Means statistics (blank to suppress) */
);
/*************************** USAGE NOTES *****************************
SAMPLE CALL:
%File_info( data=MyData )
prints contents, first 10 obs, and default statistics for
MyData data set.
*********************************************************************/
/*************************** UPDATE NOTES ****************************
10/13/04 Added freqvars option to do frequency tables.
*********************************************************************/
%***** ***** ***** MACRO SET UP ***** ***** *****;
%***** ***** ***** ERROR CHECKS ***** ***** *****;
%***** ***** ***** MACRO BODY ***** ***** *****;
title2 "File = &data";
%if %mparam_is_yes( &contents ) %then %do;
proc contents data=&data;
run;
%end;
%if &printobs > 0 %then %do;
proc print data=&data (obs=&printobs);
%if %mparam_is_yes( &printchar ) %then %do;
var _char_;
title3 "Printing first &printobs obs. (char. vars. only)";
%end;
%else %if %length( &printvars ) > 0 %then %do;
var &printvars;
title3 "Printing first &printobs obs. (selected vars.)";
%end;
%else %do;
title3 "Printing first &printobs obs.";
%end;
run;
title3;
%end;
%if %length( &stats ) %then %do;
options nolabel;
proc means data=&data &stats;
run;
options label;
%end;
%if %length( &freqvars ) %then %do;
proc freq data=&data;
tables &freqvars / missing;
run;
%end;
%exit:
%***** ***** ***** CLEAN UP ***** ***** *****;
title2;
%mend File_info;
/************************ UNCOMMENT TO TEST ***************************
%File_info( data=Sashelp.Shoes, freqvars=region product )
/**********************************************************************/