Professional > Table scripting > Table specification syntax > Special elements > Displaying median and percentile values
 
Displaying median and percentile values
Sample Script File: SpecialElements.mrs
This example script is based on the Museum sample data set. See Running the sample table scripts for information on running the example scripts.
This example is based on the Museum sample data set.
You can add a median as a row or column on a numeric variable. This shows the value above and below which 50% of cases fall.
visits{base(), median(visits)}
You can also add one or more percentiles. This is the value below which a certain percentage of the cases fall. To add a percentile you need to include a cut-off value to specify the percentage:
visits{base(), percentile(visits, 25)}
Note that the median is identical to a percentile with a cut-off value of 50.
Example
This example displays the base, lower quartile (cases that fall below the 25th percentile), median (cases that fall below the 50th percentile) and upper quartile (cases that fall below the 75th percentile) for the visits variable. As it uses two percentile elements, each has a unique name, percentile25 and percentile75:
visits{base(), percentile25 'Lower quartile' percentile(visits,25), median 'Median' median(visits), percentile75 'Upper quartile'
percentile(visits,75)}
Here is a table that has this axis on the side:
For information on how to display medians and percentiles as cell items rather than as rows or columns of a table, see Cell contents.
See also
Special elements