960.390 - Introduction to Computers for Statistics

960.390-02, Fall 1997, M 7,8 (6:10-9:00pm), Hill Center, Room 013
Meeting dates: 10/13, 10/20, 10/27, 11/3, 11/10


PROC MEANS

PROC MEANS is the first of the real-world functions that everybody uses. It's usage, though is very simple:

proc means data=mydata;
run;
This generates a table which displays, for each variable in the data set; the number of observations with the variable not missing, the mean, the standard deviation and the minimum and maximum values.

You can limit the variables by adding a line like "var height weight;" as an instruction/parameter line. You can change which statistics are printed by putting in different options:

OptionWhat it causes to be included
MAXthe maximum value of the variable
MEANthe mean value of the variable
MINthe minimum value of the variable
Nthe number of observations with the variable not missing
NMISSthe number of observations with the variable missing
RANGEthe range values of the variable
STDthe standard deviation of the variable
SUMthe sum of the values of the variable

For example:

options linesize=78 nodate formdlim="-";
data form;
input low high profit;
cards;
432 433 35.23
532 533 24.32
632 633 -87.20
732 733 0.32
;
proc means mean n std sum data=form;
var low profit;
run;
produces output:
------------------------------------------------------------------------------
 
                                The SAS System                               1

            Variable          Mean  N       Std Dev           Sum
            -----------------------------------------------------
            LOW        582.0000000  4   129.0994449       2328.00
            PROFIT      -6.8325000  4    55.5272470   -27.3300000
            -----------------------------------------------------

Similarly to the PROC PRINT command, it is possible to do calculations with a "by varname;" style. Again, the data should be sorted by the variable before the MEANS procedure is run. Like this:

options linesize=78 nodate formdlim="-";
data form;
input low high profit;
if (profit < 0) then ouch = "YES";
else ouch = "NO";
cards;
432 433 35.23
532 533 24.32
632 633 -7.20
732 733 0.32
832 633 -5.43
;
proc sort data=form;
by ouch;
run;
proc means mean std sum data=form;
var profit;
by ouch;
run;
producing output:
------------------------------------------------------------------------------
 
                                The SAS System                               1

                   Analysis Variable : PROFIT


----------------------------------- OUCH=NO ----------------------------------


                           Mean       Std Dev           Sum
                   ----------------------------------------
                     19.9566667    17.8593402    59.8700000
                   ----------------------------------------

----------------------------------- OUCH=YES ---------------------------------


                           Mean       Std Dev           Sum
                   ----------------------------------------
                     -6.3150000     1.2515790   -12.6300000
                   ----------------------------------------

Home | Syllabus | Resources | Roster | Outline | Final | Grades | Email parelius@rci.rutgers.edu

Questions or comments on this page should be sent to parelius@rci.rutgers.edu