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


data one;                  
   input mid $ year amount;
   cards;                  
A 1990 22                  
A 1991 35                  
A 1992 10                  
B 1990 30                  
B 1991 5                   
B 1992 20
;        


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


proc sort data=one out=one; 
   by mid descending amount;
run;                        


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


data two;                   
   set one;                 
   length color $8 value $5;
   count+1;                 

   select(year);                           
      when(1990) do;                       
       color='black'; value='empty';       
      end;                                 
      when(1991) do;                       
       color='black'; value='x3';          
      end;                                 
      when(1992) do;                       
       color='graycc'; value='solid';      
      end;                                 
   end;                                    
                                           
   call symput('color'||left(count),color);
   call symput('value'||left(count),value);
   call symput('total',count);             
run;


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


options mprint;                         
   %macro patterns;                     
     %do i=1 %to &total;                
      pattern&i v=&&value&i c=&&color&i;
     %end;                              
   %mend;                               
   %patterns; 


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


   %annomac;                               
                                           
data legend;                               
   %dclanno;                               
   %system(3,3,3);                         
   %bar(20,1,25,3,black,0,empty);          
   %label(26,2,'1991',black,0,0,3,centb,>);
   %bar(45,1,50,3,black,0,x3);             
   %label(51,2,'1992',black,0,0,3,centb,>);
   %bar(70,1,75,3,graycc,0,solid);         
   %label(76,2,'1993',black,0,0,3,centb,>);
run;


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


goptions ftext=zapf htext=4 pct htitle=6 pct;     
proc gchart data=two;                             
   title 'Subgroups Ordered by Value';            
   footnote1 h=4 ' ';                             
   vbar mid / subgroup=count sumvar=amount width=8
              maxis=axis1 raxis=axis1             
              nolegend anno=legend;               
   axis1 label=none;                              
run;                                              
quit;


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