BookmarkSubscribeRSS Feed
Peter_Y
Calcite | Level 5

Hello:

   I wonder if there is an easy way to produce bar plots that track donation progress? Suppose there are 3 sites 1,2,3 which finish certain percentages of their fundraising target e.g 3k out of 5k, 5k out of 10k and 7k out of 10k. I hope to plot 3 bars and the height of each bar represents the target. Inside each bar, it shows the amount already raised (with a different color) as well as the percentage.  Data is easy but not sure how to plot it in SAS. 

 

Thanks,

Peter

3 REPLIES 3
ballardw
Super User

It really helps to have actual data.

 

Here is some data and one way to plot something I hope is at least similar to what you want.

data have;
   input site $ collected target;
   pctofgoal= collected/target;
   format pctofgoal percent8.;
   label target='Target' 
         collected='Collected to Date'
   ;
datalines;
AAA   7000 10000
BBB   4000 8000
CCC   10000 8000
;

proc sgplot data=have;
   vbar site /response=target datalabel fillattrs=(color=red transparency=.3);
   vbar site /response=collected datalabel=pctofgoal fillattrs=(color=green transparency=.3);
   yaxis label='Amount';
run;

Transparency settings allow colors to combine a bit so you can see the two bars superimposed. I included one example with the amount collected larger than the target so you could see what that might do.

DanH_sas
SAS Super FREQ

Here is another variation on @ballardw 's solution, where it shrinks the width of the overlaid bar chart. I kind of like having that bar be a little smaller. It still gives you the benefit of superimposing the charts, but they still look distinct. Either will work fine. I just showing some possibilities...

 

proc sgplot data=have;
   vbar site /response=target datalabel fillattr=(color=green);
   vbar site /response=collected datalabel=pctofgoal barwidth=.4
              fillattrs=(color=yellow transparency=0.5);
   yaxis label='Amount';
run;

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
  • 983 views
  • 3 likes
  • 4 in conversation