/* Create the SALES data set for selected cities      */ 
   /* and their sales counts.                            */ 
data sales;                                                 
   input site $1-8 salescnt;                                
   cards;                                                   
Atlanta  103                                                
Chicago  486                                                
Dallas   195                                                
Denver   400                                                
New York 307                                                
Seattle  577                                                
;                                                          

   /* Calculate the percentage of sales for each         */
   /* site. The OUT= option creates a new data set,      */
   /* SALESPCT, which contains the original variable,    */
   /* SITE and a new variable, PERCENT. PERCENT          */
   /* contains the percentage of sales for each site.    */
proc freq data=sales;                                      
   tables site/out=salespct;                               
   weight salescnt;                                        
run;                                                       

   /* Create a format to display the percentages         */ 
   /* without decimal places and append a percent sign   */ 
   /* to the end of the values. If you are running       */ 
   /* Release 6.07, you can take advantage of the        */ 
   /* ROUND option. This option works the same as        */ 
   /* the ROUND function and is specified in the         */ 
   /* PICTURE statement after the format name.           */ 
proc format;                                               
   picture pctfmt (round) 0-high='000%';                   

   /* If you are running Release 6.06 or earlier         */ 
   /* of the SAS System, use the ROUND function          */ 
   /* in a DATA step to round the variable PERCENT       */ 
   /* to an integer, and remove the ROUND option         */ 
   /* from the PICTURE statement. Below is an example    */ 
   /* of the DATA step:                                  */ 
   /*                                                    */
   /* data salespct;                                     */
   /*    set salespct;                                   */
   /*    percent=round(percent,1);                       */
   /*                                                    */
   /* Use the SALESPCT data set you created in the       */
   /* FREQ procedure in the PROC GCHART statement.       */
proc gchart data=salespct;                                

   /* The GOPTIONS statement assigns a height of 3       */
   /* percent for the text with the HTEXT= option,       */
   /* and the FTEXT= option specifies SWISS as the       */
   /* default font.                                      */
goptions htext=3 pct ftext=swiss;                         

   /* Assign a title. Then use the PIE statement to      */
   /* create the graph. The chart variable is SITE,      */
   /* which represents the selected cities. The          */
   /* SUMVAR= variable PERCENT, was created by PROC      */
   /* FREQ. The NOHEADING option suppresses the          */
   /* default heading normally printed at the top of     */
   /* the pie chart output. The FORMAT statement         */
   /* assigns the format PCTFMT. to the variable         */
   /* PERCENT. The PATTERN statements assign the         */
   /* pattern fill definitions for the pie slices.       */
   /* The C= option assigns the color black to           */
   /* each pattern.                                      */
title1 h=5 pct 'Sales Percentages for Selected Sites';    
   pie site/sumvar=percent noheading;                     
   format percent pctfmt.;                                
   pattern1 v=p1x30 c=black;
   pattern2 v=p3n60 c=black; 
   pattern3 v=p2x120 c=black;
   pattern4 v=p4n145 c=black;
   pattern5 v=p3x275 c=black;
   pattern6 v=p5n180 c=black;
run;