Using Proc SGPannel. Please see following code:
proc sgpanel
data=sas_1.importance_long_many_variables;
panelby Indicator
/
rows=4 layout=rowlattice noheader spacing=11
;
histogram Count
/
datalabel=count
datalabelattrs=(color=navy family=arial size=8)
;
inset Indicator
/
position=right textattrs=(size=14)
;
rowaxis offsetmin=0
;
run;
Would like to overlay the histogram with three vertical lines:
Quartile 1
Mean
Quartile 3
The purpose is to compare various histograms (using same scale).
The above possibility does not appear in the documentation for sgpannel, histogram.
Any thoughts appreciated.
Thanks!
Nicholas Kormanik
If I am right, see if you can use this as a template. You can add labels and different coloring as you like
proc summary data = sashelp.iris nway;
class Species;
var SepalLength;
output out = temp mean(SepalLength)= mean
q1(SepalLength) = q1
q3(SepalLength) = q3;
run;
data plot;
merge sashelp.iris temp;
by Species;
run;
proc sgpanel data = plot;
panelby Species / rows=3 layout=rowlattice;
histogram SepalLength;
refline mean / axis = x;
refline q1 / axis = x;
refline q3 / axis = x;
run;
I don't think this is possible directly. I think you have to pre-compute them.
Also, are you sure you want to plot Quintiles ? Don't you mean the first and third quartile?
If I am right, see if you can use this as a template. You can add labels and different coloring as you like
proc summary data = sashelp.iris nway;
class Species;
var SepalLength;
output out = temp mean(SepalLength)= mean
q1(SepalLength) = q1
q3(SepalLength) = q3;
run;
data plot;
merge sashelp.iris temp;
by Species;
run;
proc sgpanel data = plot;
panelby Species / rows=3 layout=rowlattice;
histogram SepalLength;
refline mean / axis = x;
refline q1 / axis = x;
refline q3 / axis = x;
run;
@NKormanik Thank you, anytime 🙂
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.