In previous videos you saw numerical and graphical methods for describing categorical variables.
Now we’ll switch over to describing numerical variables.
The most basic, and probably most commonly used way to describe the typical person in a population with respect to some
characteristic that is recorded as a numerical variable, like height or weight, is with a measure of central tendency.
In this lecture we’ll discuss three measures of central tendency:
The mean
The median
And the mode
I’ve already told you that this is not a statistics course, and it’s not, but here we briefly discuss these measures and some of
their characteristics to make sure that we’re all on the same page when we discuss interpretation of SAS output.
When we talk about the typical, or “average”, value of some variable measured on a continuous scale,
we are usually talking about the mean value of that variable,
and to be even more specific we are usually talking about the arithmetic mean value.
And this value has some favorable characteristics that make it a good description of central tendency.
For starters it’s simple.
Most people are familiar with the mean and at the very least, have some intuitive sense of what it means
In addition, for any set of values, there can be only one mean value.
However, there is also a potentially problematic characteristic of the mean:
It’s susceptible to extreme values in your data.
In other words, a couple of people with very atypical values for the characteristic you are interested in,
can drastically alter the value of the mean, and your estimate for the typical person in your population of interest along with it.
And finally, it’s very possible to calculate a mean value that is not actually observed anywhere in your data.
For instance, the mean weight for our class could be 133 pounds even if nobody in the class actually weighs 133 pounds.
The median is probably the second most commonly used measure of central tendency.
And like the mean it’s computationally simple and relatively straightforward to understand
There can be one, and only one, median
And its value may also be unobserved in the data.
However, unlike the mean, it’s relatively resistant to extreme values.
In fact, when the median is used as the measure of central tendency,
it’s often because the person conducting the analysis suspects that extreme values in the data are likely to distort the mean.
And finally we have the mode, or the value that is most often observed in the data.
It doesn’t get much more simple than that.
But, unlike the mean and the median, there can be more than one mode for a given set of values.
In fact, there can even be no mode if all the values are observed the exact same number of times.
However, if there is a mode, by definition it’s observed in the data.
Now that we are all on the same page with respect to the fundamentals of central tendency,
let’s take a look at how to calculate these measures using SAS.
Here we have a basic PROC MEANS step, no options, no additional statements.
All we are giving SAS is the name of the data set we are using.
Here is the summary report created by SAS.
As you can see, by default SAS calculates the N, the mean, the standard deviation, the minimum value,
and the maximum value for every numerical variable in the data set.
The first column gives the variable names.
Here, N is the number of observations with a non-missing value for this particular variable.
Before we start refining our SAS code, I want to point out the utility of using PROC MEANS to check your data.
And what do I mean by that?
Well, we’ve already talked a little bit about data checking.
Often times, for various reasons, some observations for a given variable take on values that don’t make sense.
PROC MEANS is one tool you can use to try to figure out if you have values in your data that don’t make sense.
For example, as you scan this report, do you see any red flags?
Look at the weight variable.
Do you really think a mean weight of 1,113 pounds sounds reasonable?
This should definitely be a red flag for you.
Now move your gaze three columns to the right and notice that the maximum value of weight is 19,000 lbs –
an impossible value for a study in human populations.
In this case the real weight was supposed to be 190 pounds,
but the person entering the data accidently got a little trigger-happy with the zero key.
Now in this case we can just go back and fix our data, but what if we didn’t know this value was an error?
What if it were a value that was technically possible, but very unlikely?
Well, we can’t just go changing values in our data.
It’s unethical, and in some cases illegal.
This makes for a good opportunity to show you how to get SAS to show us the median instead of the mean,
and demonstrate to you what I meant when I said that the median is more resilient to extreme values.
If you go to the SAS documentation for PROC MEANS, it will give you a list of keywords you can use to control which statistics are
produced when you run the means procedure.
I encourage you to play around with them and see how the work.
Here you can see, and should already know, that the default is to display the number of non- missing values,
the mean, the standard deviation, the minimum value and the maximum value.
Suppose I’m interested in seeing all the default statistics, but I want to add the median and the mode.
Here you can see that I’m doing so by adding the MEDIAN option and the MODE option to the PROC statement.
I also want you to notice that once I add the median and mode to the report I have to
specifically request the other statistics that we previously got by default if I want to view them.
Additionally, notice that I put the MAXDEC option in the PROC statement.
What do you think the MAXDEC option does?
The MAXDEC option limits the number of decimal places displayed in the output, which makes it a little easier to read.
Because at the moment I’m only interested in displaying the statistics of interest for the variable weight,
I’m going to use a VAR statement followed by the variable name: wgt_lbs.
Here the mean is still 1,113 pounds and the maximum value for weight is still 19,000 pounds.
However, you will see that despite the fact that this impossibly extreme value remains in the data,
the median estimate is a reasonable estimate of the average person’s weight in this sample.
This is what we mean by “resistant to extreme values.”
However, you will also notice that the value of the median, 176.5,
is not the actual weight of anyone in this sample.
Finally, we have the mode. It’s value, 176, is also a much more reasonable estimate of the average persons weight than the mean is.
And unlike the mean and the median participants 18 and 19 actually weigh 176 pounds.
Now it’s your turn to practice calculating the three measures of central tendency.