|
Subject: SASTip: Multiple output statements with SUMMARY
Summary: PROC MEANS and SUMMARY are intertwined.
Respondent: Ian Whitlock <whitloi1@westat.com>
Phil Mason <wood-st@cityscape.co.uk> offered:
> In PROC SUMMARY you can have multiple OUTPUT statements. This
> enables a variety of stats to be calculated and written to a range of
> datasets.
>
> ===> Example (SAS log)
>
>
> 257 proc summary data=sasuser.houses ;
> 258 class style bedrooms ;
> 259 var sqfeet price ;
> 260 output out=price(keep=style bedrooms price) sum= ;
> 261 output out=average mean= ;
> 262 output out=top(where=(_type_=3)) ;
> 263 run ;
>
> NOTE: The data set WORK.PRICE has 20 observations and 3 variables.
> NOTE: The data set WORK.AVERAGE has 20 observations and 6 variables.
> NOTE: The data set WORK.TOP has 55 observations and 7 variables. NOTE:
> The PROCEDURE SUMMARY used 0.33 seconds.
And Tim Berhill <TWB2%Rates%FAR@GO50.COMP.PGE.COM> asked for comments on why
TOP restricted to _TYPE_=3 has more records than the other sets?
One must remember that there used to be two PROCS - an old MEANS which
many old users refused to give up and a SUMMARY redesigned for
efficient use. After many years of trying to get users to switch, SI
melded the two procedures into one set of code with two parsers when
version 6 was introduced.
Both PROCs now give the SUMMARY type of data set when statistics are
asked for on the OUTPUT statement. But when no statistics are asked
for in PROC MEANS, you get the old MEANS type of data set which by
default gives 5 lines of statistics for each class level. PROC SUMMARY
will not do this if there is no VAR statement present. But when there
is a VAR statement present and no statistics are asked for it will
switch to the old MEANS data set. Since there are 11 class levels with
_TYPE_ = 3 the output for TOP will have 55 records.
Ian Whitlock
|