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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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