BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NKormanik
Barite | Level 11

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

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?

PeterClemmensen
Tourmaline | Level 20

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
Barite | Level 11
Beautifully done, draycut. Thanks for your help.
PeterClemmensen
Tourmaline | Level 20

@NKormanik Thank you, anytime 🙂

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 4 replies
  • 1532 views
  • 1 like
  • 2 in conversation