BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Amine_Khemiri
Obsidian | Level 7

Dear All,

 

I'm working with PROC SGPANEL to create side-by-side bar charts for two different metrics (e.g., Response Rate and Adverse Event Rate), each associated with a distinct set of treatment groups:

  • Response Rate: Treatments 1, 2, 3

  • Adverse Event Rate: Treatments 4, 5, 6

The issue:

When using PROC SGPANEL, I get empty categories (Trt4, Trt5, Trt6) displayed in the Response panel, and Trt1–3 in the Adverse panel — even though those combinations do not exist in the data.

I've tried using:

  • categoryorder=data

  • layout=columnlattice and onepanel

  • Formatting Treatment with proc format

But the empty bars still appear.

 

Below is my SAS code for you reference. how can this be fixed?

 

data treatment_data;
input Treatment Metric $ Value;
datalines;
1 ResponseRate 75
2 ResponseRate 65
3 ResponseRate 80
4 AdverseEventRate 20
5 AdverseEventRate 25
6 AdverseEventRate 15
;
run;

/* Create dynamic treatment labels */
data treatment_data_labeled;
set treatment_data;
length TreatmentLabel $10;
TreatmentLabel = "Trt" || strip(put(Treatment, 1.));
run;

ods graphics / width=800px height=400px;

proc sgpanel data=treatment_data_labeled;
panelby Metric / onepanel novarname;
vbar TreatmentLabel / response=Value datalabel
fillattrs=(color=steelblue)
stat=mean;
colaxis display=(nolabel);
rowaxis label="Percentage";
title "Bar Charts for Treatments by Metric";
run;

 

Thanks a lot fotr your help

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

The default behavior for SGPANEL Panelby statement is to use UNISCALE=ALL, meaning the row and column axis appear the same for each panel. You can get different column axis appearance by using UNISCALE=ROW.

 

proc sgpanel data=treatment_data_labeled;
panelby Metric / onepanel novarname uniscale=row;
vbar TreatmentLabel / response=Value datalabel
fillattrs=(color=steelblue)
stat=mean;
colaxis display=(nolabel);
rowaxis label="Percentage";
title "Bar Charts for Treatments by Metric";
run;

View solution in original post

2 REPLIES 2
ballardw
Super User

The default behavior for SGPANEL Panelby statement is to use UNISCALE=ALL, meaning the row and column axis appear the same for each panel. You can get different column axis appearance by using UNISCALE=ROW.

 

proc sgpanel data=treatment_data_labeled;
panelby Metric / onepanel novarname uniscale=row;
vbar TreatmentLabel / response=Value datalabel
fillattrs=(color=steelblue)
stat=mean;
colaxis display=(nolabel);
rowaxis label="Percentage";
title "Bar Charts for Treatments by Metric";
run;
Amine_Khemiri
Obsidian | Level 7
Thank you very much!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1123 views
  • 2 likes
  • 2 in conversation