BookmarkSubscribeRSS Feed
nnl3256
Obsidian | Level 7

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;

 

 

4 REPLIES 4
DanH_sas
SAS Super FREQ

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;
nnl3256
Obsidian | Level 7

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;
DanH_sas
SAS Super FREQ

I'm not quite sure of what you need. Can you post a picture?

nnl3256
Obsidian | Level 7

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-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
  • 1987 views
  • 0 likes
  • 2 in conversation