/******************* URBAN INSTITUTE MACRO LIBRARY *********************
: File_info
Macro: Autocall macro to print basic information for a
Description: contents, first few obs., and descriptive statistics.
data set
: Open code
Use
: Peter Tatian
Author
***********************************************************************/
File_info(
%macro 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 CALLFile_info( data=MyData )
%10 obs, and default statistics for
prints contents, first
MyData data set.*********************************************************************/
/*************************** UPDATE NOTES ****************************
10/13/04 Added freqvars option to do frequency tables.
*********************************************************************/
***** ***** ***** MACRO SET UP ***** ***** *****;
%
***** ***** ***** ERROR CHECKS ***** ***** *****;
%
***** ***** ***** MACRO BODY ***** ***** *****;
%
"File = &data";
title2
%if %mparam_is_yes( &contents ) %then %do;
=&data;
proc contents data
run;
%end;
%if &printobs > 0 %then %do;
=&data (obs=&printobs);
proc print data%if %mparam_is_yes( &printchar ) %then %do;
var _char_;"Printing first &printobs obs. (char. vars. only)";
title3
%end;%else %if %length( &printvars ) > 0 %then %do;
&printvars;
var "Printing first &printobs obs. (selected vars.)";
title3
%end;%else %do;
"Printing first &printobs obs.";
title3
%end;
run;
title3;
%end;
%if %length( &stats ) %then %do;
options nolabel;=&data &stats;
proc means data
run;
options label;
%end;
%if %length( &freqvars ) %then %do;
=&data;
proc freq data&freqvars / missing;
tables
run;
%end;
:
%exit
***** ***** ***** CLEAN UP ***** ***** *****;
%
title2;
%mend File_info;
/************************ UNCOMMENT TO TEST ***************************
File_info( data=Sashelp.Shoes, freqvars=region product )
%/**********************************************************************/
Print Dataset Info
Purpose: Autocall macro to print basic information for a data set: contents, first few observations, and descriptive statistics.