multisummary Calculate Summary statistics for multiple variables multisummary

SAS Macro Programs: multisummary

$Version: 1.0 (15 Dec 2005 08:56:02)
Michael Friendly
York University


The multisummary macro ( [download] get multisummary.sas)

Calculate Summary statistics for multiple variables

The MULTISUMMARY macro produces an output data set containg any of the statistics calculated by PROC SUMMARY for any number of numeric variables.

Usage

The MULTISUMMARY macro is defined with keyword parameters. The arguments may be listed within parentheses in any order, separated by commas. For example:

  %multisummary(var=x1-x3, stats=n mean std);

Parameters

DATA=
The name of the input data set [Default: DATA=_LAST_]
VAR=
The name of the variable to be analyzed [Default: VAR=_NUMERIC_]
CLASS=
Name(s) of 0 or more class variables
STATS=
List of names of the output statistics to calculate, e.g., MEAN, MEDIAN, Q1, Q3, etc. Any of the statistic keywords accepted by PROC SUMMARY.
OPTIONS=
Options for PROC SUMMARY, e.g., nway, missing...
OUT=
The name of the output data set. The observations in this data set correspond to the combinations of the levels of all class variables with the set of statistics specified in the STATS= option.

Example

%include macros(multisummary);        *-- or include in an autocall library;
%include data(guerry);

%multisummary(data=guerry,
   class=region,
   var=Suicides Infants Crime_prop  Crime_pers,
   stats=Q1 median Q3,
   options=missing nway,
   out=gstats);

proc print data=gstats;
  Obs  _statistic_  Region  _TYPE_  _FREQ_  Suicides  Infants   prop    pers

    1    Q1                    1       1      37016    24743     4589    2199
    2    median                1       1      37016    24743     4589    2199
    3    Q3                    1       1      37016    24743     4589    2199
    4    Q1           C        1      17      15272    14475     6516   17722
    5    median       C        1      17      29381    17044     8236   21292
    6    Q3           C        1      17      77823    20046    12141   26747
    7    Q1           E        1      17      16171    12512     5914   13396
    8    median       E        1      17      21233    15599     7770   18835
    9    Q3           E        1      17      34476    20384     9044   26231
   10    Q1           N        1      17       8334    10575     4500   15602
   11    median       N        1      17      13463    14281     5521   23101
   12    Q3           N        1      17      25572    16303     7144   28180
   13    Q1           S        1      17      19024    15250     6731    8236
   14    median       S        1      17      48783    20383     8680   13019
   15    Q3           S        1      17      66498    23771     9797   13576
   16    Q1           W        1      17      25143    17681     6842   18712
   17    median       W        1      17      33358    21375     7566   22138
   18    Q3           W        1      17      38501    31754     8943   24964

See also

dummy Construct dummy variables for regression models
meanplot Plot means for factorial designs
stat2dat Convert summary dataset to raw data equivalent
sort Generalized dataset sorting by format or statistic
table Construct a grouped frequency table, with recoding