BookmarkSubscribeRSS Feed
RobbA
Calcite | Level 5
I am trying to make it easy for the person doing quality control on my graph. I have the following gplot statement:


symbol1 interpol=BOX25 color=black width=1 bwidth=4 mode=include;

proc gplot data=comb1 gout=work.heartih ;
plot hr * grp / anno=anno name='route'
haxis=axis1
vaxis=axis2 ;
ods output route=temp;
run;


As a result, SAS is creating the Q1, Q3 and Median values within the statement like a black box. I would like to be able to pump those values out to some external dataset so that someone could verify that what gplot is doing is actually what is expected. This would be a much more accurate way of checking that using the eyeball on the printed graph. Any help would be appreciated. Thanks
4 REPLIES 4
GraphGuy
Meteorite | Level 14
If knowing the exact numbers used in the boxplot is important, you might want to try "proc boxplot" (part of SAS/STAT, rather than SAS/GRAPH) - it has an "outbox=" option that will let you create a data set containing the actual numbers.

http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/statug_boxplot_sect015.htm
RobbA
Calcite | Level 5
Yes, I could do that, but I'm sort of back to where I started (having a different proc to give me numbers for QC). I didn't use proc boxplot to begin with because I couldn't see how to get rid of the 'whiskers'. My spec calls for a box plot showing the range (box) between Q1 and Q3 with the median. Hence I went with gplot and the box25 in the symbol statement. Is there a way to get this with boxplot? Thanks
GraphGuy
Meteorite | Level 14
Hmm ... I see 2 other alternatives (there might be other alternatives using GTL or sgplot, etc, that I don't know about).

1 - Use proc boxplot (or other sas analytics procs) to generate a data set containing the values describing the boxplot, and then use annotate to actually draw the boxplot geometry onto an empty gplot set of axes. This would take a bit of work, but it *could* be done this way (I've done something similar in a special dashboard before).

2 - Use dev=activex to draw the SAS/GRAPH gplot bar chart, and then have your QA person view the graph in a browser, and hover their mouse over the boxes to see the actual box values. This is still a bit manual/interactive, but at least you get to see the actual/exact numeric values used in the boxplot (median, low, high, 25th percentile, 75th percentile). Below is some code:



%let name=plt036;
filename odsout '.';

GOPTIONS DEVICE=activex;
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm";

symbol1 interpol=BOX25 color=black width=1 bwidth=4 mode=include;

title "Activex boxplot: hover over boxes to see values";
proc gplot data=sashelp.cars;
plot msrp * type;
run;

quit;
ODS HTML CLOSE;
ODS LISTING;
DanH_sas
SAS Super FREQ
Assuming you have SAS 9.2, you can do this using the Graph Template Language. The program below will draw a boxplot without the end caps. I used the ODS OUTPUT statement to generate an output dataset so you can verify the numbers. Let me know if you have any questions.

Thanks!
Dan

proc template;
define statgraph boxplot;
begingraph;
layout overlay;
boxplot x=age y=height / display=(fill mean median outliers);
endlayout;
endgraph;
end;
run;

ods output sgrender=boxdata;
proc sgrender data=sashelp.class template=boxplot; run;

proc print data=box; run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1300 views
  • 0 likes
  • 3 in conversation