BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DmytroYermak
Lapis Lazuli | Level 10

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;

Title2.jpg

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.

View solution in original post

8 REPLIES 8
Reeza
Super User

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. 

 

DmytroYermak
Lapis Lazuli | Level 10

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?

FreelanceReinh
Jade | Level 19

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.

Quentin
Super User

Nice!  I hadn't noticed WHISKERPCT.  Always dangerous to say SAS can't do something. : )

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
Reeza
Super User

@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! 🙂

 

 

Quentin
Super User

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/

 

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
DanH_sas
SAS Super FREQ

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

DmytroYermak
Lapis Lazuli | Level 10

Thank you  all! WHISKERPCT= option   has worked out.

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 3182 views
  • 11 likes
  • 5 in conversation