Due to user complain the difficulty about understanding the meaning of box plot, I ‘translate’ the box plot to histogram. Why the chref=green and whref=3 don’t work in proc univariate? Is there better way to do this?
/*Generate box plot: options must have*/ ods pdf file="&pdfout\box.pdf" notoc; title; ods graphics / reset=all height=2.7 in width=4.3in; ods graphics on / border = off; ods graphics on / imagemap=on; Title1 h=1.4 j=c font=Arial bold "Age Summary - box"; proc sgplot data=class; hbox age; refline &ag1 /axis=x lineattrs=(color=green thickness=3) label=("&nm1: &ag1") labelloc=inside; run; quit; ods pdf close; /*Generate histogram*/ ods pdf file="&pdfout\hist.pdf" notoc; title; ods graphics / reset=all height=2.7 in width=4.3in; ods graphics on / border = off; ods graphics on / imagemap=on; Title1 h=1.4 j=c font=Arial bold "Age Summary - hist"; proc univariate data=sashelp.class noprint; histogram age / midpoints = 10 to 20 by 1 rtinclude href=&ag chref=green whref=3 hreflabel="&nm1: &ag1" outhistogram = OutMdpts; run; quit; ods pdf close;
Those options on UNIVARIATE might only work with GRSEG-based output. SGPLOT also has a HISTOGRAM statement, and you can overlay REFLINEs behind or in front of the histogram. You can also control the attributes of the REFLINEs. Here is a simple example:
proc sgplot data=sashelp.heart; histogram cholesterol; refline 200 / axis=x lineattrs=(color=red thickness=2); refline 300 / axis=x lineattrs=(color=green thickness=2); run;
Thank you very much. This refline seems a little bit of misleading. What I really need is an indicator to highlight the cross point of age and percent for a student, for example to indicate Carol belongs to 20% distribution group, not necessary a refline. The indicator label should be like “Carol: 14”. Welcome suggestion or creation.
proc sql noprint; select name, age into :nm, :ag from sashelp.class where name="Carol"; quit; %let ag1=&ag; %let nm1=&nm; proc sgplot data=sashelp.class; histogram age ; refline &ag / axis=x label ="&nm1: &ag1" labelloc=inside lineattrs=(color=green thickness=2); run;
It was so nice to meet you in person around the SAS Global Forum 2018. I agree with your explanation, i.e., the 'translation' doesn't work well. Thank you. By the way the supper demo is great, and I am thinking to attend in 2019. Hopefully see you there!
SAS is headed back to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team.
Interested in speaking? Content from our attendees is one of the reasons that makes SAS Innovate such a special event!
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.