/**********************************************************************/


data goodies;                    
   input dessert $27. votes;     
   cards;                        
Georgia Peach Pie            460 
Blueberry Pound Cake         475 
Peanut Butter Fudge Brownie  420 
Jiffy Goober Bar             500
;                               
                                
proc sort data=goodies;         
   by dessert;                  
run;                            


/**********************************************************************/


data _null_;                           
   set goodies end=eof;                
   call symput('dsert'||left(_n_),"'"||
                trim(dessert)||"'");   
      if eof then do;                  
      call symput('total',_n_);        
   end;                                
run;                                   


/**********************************************************************/


%macro mcdoloop;      
   %do i=1 %to &total;
     &&dsert&i        
   %end;              
%mend mcdoloop;       


/**********************************************************************/


value=('Georgia Peach Pie'          
       'Blueberry Pound Cake'       
       'Peanut Butter Fudge Brownie'
       'Jiffy Goober Bar')          


/**********************************************************************/


goptions ftext=zapfi ftitle=zapfb;         
title1 height=2 c=black                    
'Macro to sidestep the 16-character limit';
title2 height=1 c=black                    
'Results of our unofficial dessert survey';
pattern1 value=solid;                      
axis1 value=(%mcdoloop) label=none;                 
axis2 label=(font=centb 'Number of votes received');
                                                    
proc gchart data=goodies;                           
   hbar dessert / discrete                          
                  sumvar=votes                      
                  maxis=axis1                       
                  raxis=axis2                       
                  nostats;                          
run;                                                
quit;                                               


/**********************************************************************/


data goodies2;                              
   length day $9;                           
   input dessert $27. day $ votes;          
cards;                                      
Georgia Peach Pie             Monday     80 
Blueberry Pound Cake          Monday     200
Peanut Butter Fudge Brownie   Monday     10 
Jiffy Goober Bar              Monday     300
Georgia Peach Pie             Tuesday    300
Blueberry Pound Cake          Tuesday    15 
Peanut Butter Fudge Brownie   Tuesday    400               
Jiffy Goober Bar              Tuesday    80                
Georgia Peach Pie             Wednesday  80                
Blueberry Pound Cake          Wednesday  250               
Peanut Butter Fudge Brownie   Wednesday  10                
Jiffy Goober Bar              Wednesday  120               
;                                                          
                                                           
proc sort data=goodies2 out=goodies3 nodupkey;             
   by dessert;                                             

data _null_;                                               
   set goodies3 end=eof;                                   
   call symput('dsert'||left(_n_),"'"||trim(dessert)||"'");
      if eof then do;                                      
         call symput('total',_n_);                         
      end;                                                 
run;                                                       
                                                           
title2 height=1 color=black                                
'Results of our 3-day vote tally';                         
axis1 label=(font=centb 'Votes') order=0 to 500 by 100;    
axis2 label=none offset=(2);                               
legend1 value=(%mcdoloop) label=none;                      
symbol1 value=M interpol=join color=black                  
font=marker line=1;                                        
symbol2 value=V interpol=join color=black                  
font=marker line=2;                                        
symbol3 value=O interpol=join color=black                  
font=marker line=3;                                        
symbol4 value=P interpol=join color=black 
font=marker line=22;                      
                                          
proc gplot data=goodies2;                 
   plot votes*day=dessert / legend=legend1
                            vaxis=axis1   
                            haxis=axis2   
                            frame;        
run;                                      
quit;                                     


/**********************************************************************/