BookmarkSubscribeRSS Feed
janneen
Calcite | Level 5

Hello!

 

I'm having some difficulties in producing a barplot using PROC SGPANEL. My value labels (panel variable) are so long that they cannot fit into  the header box. I have tried to decreace fontsize together with adjusting some size options. Is there a way to cut the label (it is a sentence) into two rows of text?

 

Janne

4 REPLIES 4
data_null__
Jade | Level 19

Perhaps

(*ESC*){newline}
ballardw
Super User

Simplest might be assign different label text just for the Sgpanel plot(s) to override the long label.

 

Here is an example of code you can run as you should have the SASHELP.CLASS data set.

This creates a data set with a default label that is moderately long, plots with that default and then overrides the default label.

data example;
   set sashelp.class;
   label sex= 'This is a ridiculously long label for a gender variable';
run;

proc sgpanel data=example;
   panelby sex;
   vbar age;
run;

/* how to override default label*/

proc sgpanel data=example;
   panelby sex;
   vbar age;
   label sex='A short label';
run;

Otherwise, provide the actual code you are running along with example data in the form of a data step that has the current label. You should also include your ODS Graphics settings as those control actual space occupied by a graph.

 

Depending on the actual graph you are making (hint) perhaps the default headers are not needed and the NOHEADER option on the Panelby might apply. The Panelby option NOVARNAME will suppress the variable name/ variable label and just show the value of the Panelby variable.

 

 

Rick_SAS
SAS Super FREQ

I don't know how to split the output, but you can use the FORMAT statement if you want to truncate the questions to some smaller length:

data Questions;
length Q $100;
Q = "This is the first questions. Do you think it is very long?";
Val = "Yes"; Count = 16;
output;
Val = "No "; Count = 14;
output;

Q = "The second question also has many words in it. Do you think it is long?";
Val = "Yes"; Count = 12;
output;
Val = "No "; Count = 18;
output;
run;

proc sgpanel data=Questions;
format Q $25.;
panelby Q / novarname;
vbar Val / freq=Count;
run;
PGStats
Opal | Level 21

You could split the strings somehow and use INSET as a workaround (thanks to @Rick_SAS for the test data):

 

data Questions;
length Q Q1 Q2 $100;
Q = "The first question. Do you think it is very long?";
Q1 = "The first question";
Q2 = "Do you think it is very long?";
Val = "Yes"; Count = 16;
output;
Val = "No "; Count = 14;
output;

Q = "The second question. Do you think it is quite long?";
Q1 = "The second question";
Q2 = "Do you think it is quite long?";
Val = "Yes"; Count = 12;
output;
Val = "No "; Count = 18;
output;
run;

proc sgpanel data=Questions;
panelby Q / noheader;
vbar Val / freq=Count;
inset q1 q2 / nolabel position=top textattrs=(size=10);
rowaxis offsetmax=0.15;
run;

PGStats_1-1649443515993.png

 

 

PG

sas-innovate-2024.png

📢

ANNOUNCEMENT

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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.

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
  • 4 replies
  • 1018 views
  • 5 likes
  • 5 in conversation