BookmarkSubscribeRSS Feed
Ujjawal
Quartz | Level 8

I am new to SAS VA. I am trying to create a bar chart showing comparison of two groups. Data for the 2 groups are in separate files (data sources). I want the chart to be displayed as shown below. Since data for the 2 groups are in separate data sources, i am able to create two bar charts but unable to combine them in a single bar chart showing 2 bars for each of the groups.

SAS VA.png

 

Any help would be highly appreciated. Thanks!

4 REPLIES 4
paulkaefer
Lapis Lazuli | Level 10

I'm new, as well, so I'm taking this as a challenge: If you reorganize your data a little, this will give the closest I can get to your picture. The bars are next to each other.

data example;
   infile datalines delimiter=',';
   input turnover $ value group;
   datalines;                      
0-5,45,1
0-5,44,2
5-10,17,1
5-10,20,2
10-15,38,1
10-15,36,2
;

/* general routine:
    http://blogs.sas.com/content/sascom/2011/08/22/how-to-make-a-cluster-grouped-bar-chart-graph-using-sas-sg-procedures/ */
proc sgplot data=example;
  vbar turnover / response=value group=group stat=sum nostatlabel
         groupdisplay=cluster barwidth=0.9 transparency=0;
  xaxis display=(nolabel);
  yaxis grid;
  run;

Otherwise, a different method will get the bars on top of each other. you can play around with barwidth and transparency to see what you like:


data example;
   infile datalines delimiter=',';
   input turnover $ group1 group2;
   datalines;                      
0-5,45,44
5-10,17,20
10-15,38,36
;

/* general routine:
    http://blogs.sas.com/content/sascom/2011/08/22/how-to-make-a-cluster-grouped-bar-chart-graph-using-sas-sg-procedures/ */
proc sgplot data=example;
  vbar turnover / response=group1 stat=sum nostatlabel
         groupdisplay=cluster barwidth=0.5 transparency=0.2;
  vbar turnover / response=group2 stat=sum nostatlabel
         groupdisplay=cluster barwidth=0.7 transparency=0.2;
  xaxis display=(nolabel);
  yaxis grid;
  run;
Ujjawal
Quartz | Level 8
My question is how to do this in SAS Visual Analytics software rather than base SAS. Thanks!
MichelleHomes
Meteorite | Level 14

As you've discovered the data needs to be in the same data source for a single visualization/report object. When you are working with a visualization/report object only 1 data source can be selected and therefore you will need to bring your groups together in the same data source if you want a clustered bar chart.

//Contact me to learn how Metacoda software can help keep your SAS platform secure - https://www.metacoda.com
ballardw
Super User

Note that your Excel example does not have the data in two different workbooks.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2505 views
  • 0 likes
  • 4 in conversation