BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Kiteulf
Quartz | Level 8
proc sgplot data=pande_app4_w_bad;

vbar Selskapspolicy / response=Bad_6m stat=mean DATALABEL
barwidth=0.6 fillattrs=graphdata1 ;
  yaxis grid display=(nolabel);
  xaxis display=(nolabel);


vbar Selskapspolicy / response=Bad_12m stat=mean DATALABEL
barwidth=0.4 fillattrs=graphdata2 ;
  yaxis grid display=(nolabel);
  xaxis display=(nolabel);
run;

image.png

 

I am not getting this as neat as I want to side by side...Anyone?

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

If you want the blue and red bars to be placed side by side, you have two options.

  1. Use DISCRETEOFFSET.  Reduce both bar widths, and use discreteoffset=-0.2 with one and discreteoffset=+0.2 with other.  You can adjust the widths and offsets to suit.
  2. Change your data set from 2 response columns to one response column with a classifier.  Then you can use the GROUP option with GROUPDISPLAY=CLUSTER to get side by side bars.  This way is more scalable and preferable.

View solution in original post

3 REPLIES 3
Jay54
Meteorite | Level 14

If you want the blue and red bars to be placed side by side, you have two options.

  1. Use DISCRETEOFFSET.  Reduce both bar widths, and use discreteoffset=-0.2 with one and discreteoffset=+0.2 with other.  You can adjust the widths and offsets to suit.
  2. Change your data set from 2 response columns to one response column with a classifier.  Then you can use the GROUP option with GROUPDISPLAY=CLUSTER to get side by side bars.  This way is more scalable and preferable.
Kiteulf
Quartz | Level 8

Yeah I want to use the Group option, but found it hard to implement as my data is of the type

 

reponsecolumn1 responsecolumn2
1 1
0 1
0 0
1 0

 

How do I get it to a one response column and a classifier?

Jay54
Meteorite | Level 14

You can use PROC TRANSPOSE.  if you have data set "Response" with Cat, Response1 and Response2, you can use the following.  The response column names will show up as group values.

 

proc transpose data=response out=groups;
  by cat;
run;

 

For a simple case like yours, I use a simple data step:

 

data groups;
  keep Cat Group Response;
  set response;
  Group=1; Response=response1; output;
  Group=2; Response=response2; output;
run;

Here is an article by Rick on this topic. 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 11138 views
  • 0 likes
  • 2 in conversation