SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 24673: Determine the MEDIAN value prior to SAS 9.0

DetailsCodeResultsAboutRate It
Determine the middle of a distribution.

Note:   If you are running a release of SAS prior to SAS 9.0, you can determine the median value of a group by using the ORDINAL function to mimic the MEDIAN function.

The syntax of the ORDINAL function is :

    ORDINAL(count,argument,argument, . . .) ;

The ORDINAL function returns the count-th largest of the arguments, beginning with the lowest value. For instance, if you specify 4 as the value of the count parameter, ORDINAL will return the 4th largest value in the series of variables or values in the argument list.

With an odd number of variables, the median will be the single value that falls at the midpoint of the distribution. See Sample 1 on the Full Code tab.

With an even number of variables, there is no single middle value, therefore the median will be the average of the two middle values in the ordered distribution. See Sample 2 on the Full Code tab.


These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.