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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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