BookmarkSubscribeRSS Feed
YNWA1
Obsidian | Level 7

Hi, I am using SG panel to achieve something similar to the below graph. I can't get it right. Any help would be appreciated.

Not sure if SG panel is the right option or should I use 4 separate SG PLOT?

(I am hiding some data for confidentiality)

 

The legend should be appear below for each Rating Type per graph.

Example: Graph3

  • TYPE1_variance
  • TYPE2_variance
  • TYPE3_variance
  • TYPE4_variance

 

YNWA1_1-1630929911258.png

 

My code and output

data prep;
infile datalines dlm=" ";
input EXCEPTION $15.LOB $2. pcnt_excpt_ratings;
datalines;
TYPE1_Variance B 2
TYPE2_Variance D 3
TYPE2_Variance B 11
TYPE2_Variance A 3
TYPE2_Variance C 19
TYPE3_Variance A 0
TYPE3_Variance B 4
TYPE3_Variance C 2
TYPE3_Variance D 0
TYPE4_Variance D 0
TYPE4_Variance B 1
TYPE4_Variance A 0
TYPE4_Variance C 1
TYPE5_Variance B 1
;
run;

title "Overall Exceptions as % of each LOB's Ratings";
proc sgpanel data=prep;
   panelby lob / novarname sparse;
   vbar Exception /response=pcnt_excpt_ratings group=Exception datalabel;
   colaxis values=(0 to 12 by 2);
   rowaxis refticks=(values) grid display=none;
   keylegend / position=bottom; 
run;
title;

YNWA1_2-1630930214283.png

 

1 REPLY 1
ballardw
Super User

Easy to try: If you data is not sorted by your LOB variable then do so. Then try SGPLOT with a BY LOB;

If that makes 4 graphs the way you want each to appear you are on your way.

 

You can use #byval in title statements to get the information you have in the "boxes" of the titles.

 

However you won't get a 2 rows of graphs with SGPLOT.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore 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
  • 1 reply
  • 1250 views
  • 0 likes
  • 2 in conversation