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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 10126 views
  • 0 likes
  • 2 in conversation