|
Hi _all_ (including _numerics_)
Here is a demo of one way in which MEANS and SUMMARY procedures differ.
SUMMARY needs the VAR statement, but MEANS doesn't!
1 proc means data=sasuser.houses;
2 class style;
3 output out=a;
4 run;
NOTE: The data set WORK.A has 25 observations and 8 variables.
NOTE: The PROCEDURE MEANS used 0.33 seconds.
9 proc summary data=sasuser.houses;
10 class style;
11 output out=b;
12 run;
NOTE: The data set WORK.B has 5 observations and 3 variables.
NOTE: The PROCEDURE SUMMARY used 0.05 seconds.
The obvious expectation in MEANS is similar to UNIVARIATE without a VAR
statement = use all numeric variables!
Not specifying the statistics required has other benefits - try it!
HTH
Diana Noble <diana.noble@PRUDENTIAL.COM> writes
>Here is a tidbit cooked up by a colleague on the Proc Summary feature.
>
>Knowing the the _NUMERIC_ keyword can be used in certain procedures, he
>intuitively used
>it in the PROC SUMMARY procedure to summarize a dataset on all NUMERIC
>variables. I
>looked everywhere in the "SAS Procedures Guide, version 6" and in the on-line
>help. Not finding it,
>I congratulated John on his outstanding discovery, which he modestly accepted
>with a puzzled
>("it only seemed natural and made sense"!)
>
>Example code is provided below. While this example has only 2 numeric variables
>the time saved
>not typing in dozens or (hundreds?) of variables could be quite appreciable.
>
>
> /* Note variable GRADE3 is CHARACTER for illustration purposes */
>DATA TEST;
> INPUT @1 STATE $2. @5 GRADE1 @10 GRADE2 @15 GRADE3 $3.;
>CARDS;
>AL 80 99 72
>NJ 50 40 73
>AL 90 97 76
>AL 100 92 70
>;
>RUN;
>
> /* sort the dataset by some variable(s) */
>
>PROC SORT DATA=TEST;
> BY STATE GRADE3;
>RUN;
>
> /* Determine the mean of all numeric variables only */
>
>PROC SUMMARY DATA=TEST NWAY;
> VAR _NUMERIC_;
> BY STATE;
> OUTPUT OUT=TEST2 MEAN=;
>RUN;
> /* view the results */
>PROC PRINT DATA=TEST2;
>RUN;
>
>******************** output ****************************************;
>OBS STATE _TYPE_ _FREQ_ GRADE1 GRADE2
>
> 1 AL 0 3 90 96
> 2 NJ 0 1 50 40
--
Peter Crawford (_knowledge_ is a poor substitute for *real* experience,
but they make a great team)
|