Hi all,
Can you please help with option in proc sgplot that displays 5 percentiles:
10th, 25th, 50th, 75th and 90th.
Here it is the code and the output:
proc sgplot data=output_1;
by SubType;
hbox AGE / category=AVAL;
run;
Thank you!
Hi @DmytroYermak,
With your SAS 9.4M5 (and SAS 9.4M2 and later releases) you can also use the WHISKERPCT= option:
hbox AGE / category=AVAL whiskerpct=10;
Then the whiskers will indicate the 10th and 90th percentile. The 25th and 75th percentile are (by default) the edges of the box and the 50th percentile the line inside the box.
What version of SAS do you have? Very specifically, such as SAS 9.4TS1M6.
The graphical options change quickly. The code below will show the image.
proc product_status;
run;
I suspect what you'll need to do is pre-calculate the percentiles (PROC SUMMARY) and then use a SCATTER or TEXT statement to plot those points correctly.
Thank yo for the replying. I have the following version:
For SAS/GRAPH ...
Custom version information: 9.4_M5
For SAS/IML ...
Custom version information: 14.3
For High Performance Suite ...
Custom version information: 2.2_M6
For SAS/ACCESS Interface to PC Files ...
Custom version information: 9.4_M5
Could you please provide a link or draft syntax of such sort of calculations?
Hi @DmytroYermak,
With your SAS 9.4M5 (and SAS 9.4M2 and later releases) you can also use the WHISKERPCT= option:
hbox AGE / category=AVAL whiskerpct=10;
Then the whiskers will indicate the 10th and 90th percentile. The 25th and 75th percentile are (by default) the edges of the box and the 50th percentile the line inside the box.
Nice! I hadn't noticed WHISKERPCT. Always dangerous to say SAS can't do something. : )
@Quentin wrote:
Nice! I hadn't noticed WHISKERPCT. Always dangerous to say SAS can't do something. : )
It's good to be wrong sometimes, glad I was as well! 🙂
So you want whiskers that extend to the 10th and 90th percentiles?
I don't think SGPLOT can do that. I think you might need to calculate the percentiles yourself, then use GTL BOXPARM to draw the box plots.
Or actually, just came across this blog post where Sanjay Matange shows a way to make a custom box plot by using SGPLOT to make a HIGHLOW plot. Looks promising.
https://blogs.sas.com/content/graphicallyspeaking/2013/03/24/custom-box-plots/
You can use the DISPLAYSTATS option to show them, but you will need to use a VBOX statement instead of the HBOX statement to use that option. Try DISPLASTATS=ALL to see all of the available stats, but you can use a parenthesized list of stats to display the ones you want.
Hope this helps!
Dan
Thank you all! WHISKERPCT= option has worked out.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.