In statistics, deciles are numbers that split a dataset into ten groups of equal frequency.
The first decile is the point where 10% of all data values lie below it.
The second decile is the point where 20% of all data values lie below it, and so forth.
You can use the following basic syntax to calculate the deciles for a dataset in SAS:
/*calculate decile values for variable called var1*/
proc univariate data=original_data;
var var1;
output out=decile_data;
pctlpts = 10 to 100 by 10
pctlpre = D_;
run;
Note: The pctlpts statement specifies which deciles to calculate and the pctlpre statement specifies the prefix to use for the deciles in the output.
The following example shows how to use this syntax in practice.
Example: How to Calculate Deciles in SAS
Suppose we have the following dataset in SAS that contains two variables:
/*create dataset*/
data original_data;
input team $ points;
datalines;
A 12
A 15
A 16
A 21
A 22
A 25
A 29
A 31
B 16
B 22
B 25
B 29
B 30
B 31
B 33
B 38
;
run;
/*view dataset*/
proc print data=original_data;
The following code shows how to calculate the deciles for the points variable in the dataset
/*calculate decile values for points*/
proc univariate data=original_data;
var points;
output out=decile_data
pctlpts = 10 to 100 by 10
pctlpre = D_;
run;
/*view deciles for points*/
proc print data=decile_data;
Here’s how to interpret the output:
- The value of the first decile is 15.
- The value of the second decile is 16.
- The value of the third decile is 21.
- The value of the fourth decile is 22.
And so on.
Additional Resources
The following tutorials explain how to perform other common tasks in SAS:
How to Calculate Percentiles in SAS
How to Calculate Quartiles in SAS
How to Use Proc Summary in SAS