SAS Institute. The Power to Know

FOCUS AREAS

The Action Menu

You can create a custom menu for a plot and associate one or more IMLPlus statements with each item on the menu. Such a menu is referred to as an action menu. To display a plot's action menu, press F11 while the plot's window is active. Choosing an item on the menu executes the IMLPlus statements associated with that item.

Action menus may contain cascading submenus.

Example

  declare DataObject dobj;
  dobj = DataObject.CreateFromFile( "Samples/business.sas7bdat" );

  declare ScatterPlot plot;
  plot = ScatterPlot.Create( dobj, "Sales", "Profits" );
  plot.SetMarkerSize( 5 );
  plot.SetObsLabelVar( "Company" );

  plot.AppendActionMenuItem( "Color Code\nBy &Nation"J,
     "run BusinessColorCode( plot, 'Nation' );"      );

  plot.AppendActionMenuItem( "Color Code\nBy &Industry"J,
     "run BusinessColorCode( plot, 'Industry' );"    );

  /* Define module to color code business data set by 
     Nation or Industry and display legend on plot */
  start BusinessColorCode( Plot plot, variable );
     if variable='Nation' then do;
        colors = RED||GREEN||YELLOW||WHITE||BLUE;
        labels = {"Britain", "France", "Germany", "Japan", "USA"};
        end;
     else if variable = 'Industry' then do;
        colors = RED||YELLOW||GREEN||BLACK;
        labels = {"Automobiles", "Electronics", "Food", "Oil"};
        end;
   
     run ColorCode( plot.GetDataObject(),
            variable, IntToRGB(colors), ncol(colors) );

     plot.DrawRemoveCommands();
     run DrawLegend( plot, labels, 8, colors, 0, -1, -1, 'IRB' );
     plot.BulletActionMenuItem( "Color Code\nBy &"J + variable );
  finish;

  /* Press F11 in the plot window to see the menu. */

Scatter plot with action menu


Statistics and Operations Research Home Page | SAS/IML Workshop