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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 855 views
  • 1 like
  • 2 in conversation