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 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:
Option | What it causes to be included |
---|---|
MAX | the maximum value of the variable |
MEAN | the mean value of the variable |
MIN | the minimum value of the variable |
N | the number of observations with the variable not missing |
NMISS | the number of observations with the variable missing |
RANGE | the range values of the variable |
STD | the standard deviation of the variable |
SUM | the 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 ----------------------------------------
Questions or comments on this page should be sent to parelius@rci.rutgers.edu