Calling PROC SGPLOT from PROC IML

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: GRSGPLOT                                            */
/*   TITLE: Calling PROC SGPLOT from PROC IML                   */
/* PRODUCT: IML                                                 */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT: Rick Wicklin                UPDATE: SEP 2013        */
/*     REF:                                                     */
/*    MISC:                                                     */
/*                                                              */
/****************************************************************/


proc iml;
x = {[7]A [8]B [3]C};  /* repetition factors: 7 As, 8 Bs, and 3 Cs */
create Bar var {x}; append; close Bar;       /* write SAS data set */

submit;
   proc sgplot data=Bar;
      vbar x;
   run;
endsubmit;

/* module to create a bar chart from data in X */
start BarChart(x);
   create Bar var {x}; append; close Bar;  /* write to SAS data set  */
   submit;
      proc sgplot data=Bar;                /* create the plot     */
         vbar x;
      run;
   endsubmit;
   call delete("Bar");                     /* delete the data set */
finish;

run BarChart(x);                           /* call the module     */