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


proc means data=&inds noprint max;                         
   var &vvar;        /* number of otters                 */
   output  out=picsize(keep=nbars vmax)                    
           max=vmax  /* maximum number of otters - width */
           n=nbars;  /* number of manuf. plants - height */
run;                                                       


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


if _n_=1 then do;             
   /* initialization code */
end;                          


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


rc=ginit();       
rc=graph('clear');
set picsize;      


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


rc=gset('colrep', 1, 'gray10');  /* symbol color        */
rc=gset('colrep', 2, 'gray30');  /* symbol color        */
rc=gset('colrep', 3, 'gray50');  /* symbol color        */
rc=gset('colrep', 4, 'gray70');  /* symbol color        */
rc=gset('colrep', 5, 'gray90');  /* symbol color        */
rc=gset('colrep', 6, 'grayb0');  /* symbol color        */
rc=gset('colrep', 7, 'grayd0');  /* symbol color        */
rc=gset('colrep', 8, 'black');   /* for text/line color */


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


call gask('window', 0, x1, y1, x2, y2, rc);              
xrange=x2-x1;  /* width of graph area in window units  */
yrange=y2-y1;  /* height of graph area in window units */


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


xlabel = .23*xrange;  /* x-coordinate for plant labels             */ 
xmin   = .25*xrange;  /* minimum \ob x\obe  dimension of the pict. */ 
xmax   = .95*xrange;  /* maximum \ob x\obe  dimension of the pict. */ 
yaxmin = .15*yrange;  /* minimum \ob y\obe  dimension of the pict. */ 
yaxmax = .95*yrange;  /* maximum \ob y\obe  dimension of the pict. */ 


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


yaxlen=yaxmax-yaxmin;              /* y-axis length       */
ywidth=floor(yaxlen/(nbars+1));    /* symbol height       */        
ymargn=(yaxlen-(ywidth*nbars))/(nbars-1);                           
                                   /* room between rows   */        


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


vmin=0;                       /* Include 0 in the data range.        */
vmax=(floor(vmax/10)+1)*10;   /* Adjust the max. value to add space  */
                              /* at the end of pict. area.           */


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


vscale=(xmax-xmin)/(vmax-vmin);


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


array pmx {18} px1-px18;


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


incr=(xmax-xmin)/dim(pmx);


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


do i=1 to dim(pmx);                        
   pmx{i}=xmin+incr/2+((i-1)*incr);
end;                                       


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


symvalue=(vmax-vmin)/dim(pmx);


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


rc=gdraw('text', .5*xrange, .13*yrange,              
         '1 symbol = ' || left(put(symvalue, 6.2)) ||
         %str(&units));                              


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


rc=gset('window', 1, 0, 0, 100, 100);
rc=gset('transno', 1);               


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


rc=gset('viewport', 1, xmin/xrange, ybar/yrange,   
                       xval/xrange, ystart/yrange);
rc=gset('window', 1, xmin, ybar, xval, ystart);    
rc=gset('transno', 1);                             
rc=gset('clip', 'on');                             


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


do i=1 to dim(pmx);                                         
   rc=gdraw('text', pmx{i}, pmy, 'V');              
end;                                                        
rc=gset('clip', 'off');                                     
rc=gset('transno', 0);   /* Return to the default window. */


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


rc=gset('texcolor', mod(_n_, ncolors) + 1);


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