Appendix C. IMLPlus Classes, Methods, and Statements

Contents

  • C.1 Overview of IMLPlus Classes, Methods, and Statements 427

  • C.2 The DataObject Class 428

  • C.3 The DataView Class 429

  • C.4 The Plot Class 429

  • C.5 Methods for Creating and Modifying Plots 431

    • C.5.1 Bar Chart Methods 432

    • C.5.2 Box Plot Methods 432

    • C.5.3 Histogram Methods 432

    • C.5.4 Line Plot Methods 433

    • C.5.5 Scatter Plot Methods 433

  • C.6 Calling SAS Procedures 433

  • C.7 Calling R Functions 434

C.1 Overview of IMLPlus Classes, Methods, and Statements

The programming language of SAS/IML Studio is called IMLPlus. IMLPlus is an extension of SAS/IML that contains additional programming features. IMLPlus combines the flexibility of programming in the SAS/IML language with the power to call SAS procedures and to create and modify dynamically linked statistical graphics. The IMLPlus language is described in Chapter 5.

The IMLPlus language is object-oriented. For example, to create a scatter plot, you instantiate an object of the ScatterPlot class. To modify the scatter plot, you call methods that are in the ScatterPlot class or in any base class. Classes and methods are described in Chapter 6; creating an IMLPlus graph is described in Chapter 7.

This appendix presents tables that contain IMLPlus methods discussed in this book and also functions that were not explicitly used in this book but that are used often in practice. This appendix also contains a section that summarizes how to submit SAS statements or R statements from SAS/IML Studio.

C.2 The DataObject Class

The most important class in the IMLPlus language is the DataObject class. The DataObject class is used to manage an in-memory copy of data. The DataObject class contains methods that query, retrieve, and manipulate the data. The class also manages graphical information about observations such as the shape and color of markers, the selected state of observations, and whether observations are displayed in plots or are excluded.

Table C.1 lists frequently used methods in the DataObject class. You can view the complete set of DataView methods from the SAS/IML Studio online Help. Choose Help C.2 The DataObject ClassHelp Topics and then expand the IMLPlus Class Reference C.2 The DataObject ClassDataObject section.

Table C.1. Frequently Used DataObject Class Methods

Method

Description

AddVar

Adds a new variable to the data object

AddVars

Adds new variables to the data object

Create

Instantiates a data object from SAS/IML matrices

CreateFromFile

Instantiates a data object from a SAS data set available from a drive on the local computer

CreateFromR

Instantiates a data object from an R data frame

CreateFromServerDataSet

Instantiates a data object from a SAS data set in a libref

GetNumObs

Returns the number of observations in the data object

GetNumVar

Returns the number of variables in the data object

GetSelectedObsNumbers

Gets the indices of selected observations

GetVarData

Gets the values for a variable

GetVarNames

Gets the names of variables

IncludeInAnalysis

Specifies whether an observation should be included in statistical analyses

IncludeInPlots

Specifies whether an observation should be included in IMLPlus graphs

IsNominal

Returns true if a variable is nominal and false otherwise

IsNumeric

Returns true if a variable is numeric and false otherwise

SelectObs

Selects observations

SelectObsWhere

Selects observations that satisfy a one-variable criterion

SetMarkerColor

Sets the color of markers that represent an observation in a plot

SetMarkerShape

Sets the shape of markers that represent an observation in a plot

SetNominal

Specifies that a variable is a classification variable

SetRoleVar

Specifies that a variable is used in a certain role, such as to label observations in a plot

SetVarFormat

Sets the SAS format associated with a variable

WriteToServerDataSet

Writes the data into a SAS data set in a libref

WriteVarsToServerDataSet

Writes the specified variables into a SAS data set in a libref

C.3 The DataView Class

The DataView class is the base class for the DataTable class and the Plot class. You cannot instantiate a DataView object, since there is not a "Create" method in the class, but you can call methods in this class from any data table and any plot.

The most frequently used methods in this class are related to positioning or showing a window. Less common methods include the methods related to action menu, which are discussed in Chapter 16, "Interactive Techniques." Table C.2 lists frequently used methods.

Table C.2. Frequently Used DataView Class Methods

Method

Description

ActivateWindow

Displays a window in the foreground

AppendActionMenuItem

Attaches a menu item to a data view. The menu is displayed when you press the F11 key.

GetDataObject

Returns the data object associated with the data view

GetInitiator

Returns the data view whose action menu was selected

IsInstance

Determines whether a plot is an object of a certain class

SetWindowPosition

Positions a data view within the main SAS/IML Studio window

ShowWindow

Displays a window

You can view the complete set of DataView methods from the SAS/IML Studio online Help. Choose HelpFrequently Used DataView Class Methods Help Topics and then expand the IMLPlus Class Reference Frequently Used DataView Class Methods DataView section.

C.4 The Plot Class

The Plot class is a base class for all plots. You cannot instantiate a Plot object, since there is not a "Create" method in the class, but you can call methods in this class from any plot.

The most frequently used methods in this class are related to modifying plot attributes or to drawing on a plot, as discussed in Chapter 9, "Drawing on Graphs." You can view the complete set of DataView methods from the SAS/IML Studio online Help. Choose Help C.4 The Plot Class Help Topics and then expand the IMLPlus Class Reference C.4 The Plot Class DataView section.

Table C.3 lists methods that are associated with getting and setting properties of a graph's axis. The first argument to each method is a keyword that specifies the axis. Valid values are XAXIS, YAXIS, or (in some cases) ZAXIS. Except for the SetAxisViewRange method (which is defined in the Plot2D class), these methods are all in the Plot class.

Table C.3. Methods Associated with Axis Properties

Method

Description

GetAxisTickAnchor

Returns the tick anchor for an axis

GetAxisTickUnit

Returns the tick unit, which is the increment between evenly spaced tick marks

GetAxisViewRange

Returns the minimum and maximum values of the axis range

SetAxisLabel

Specifies the label for an axis

SetAxisMinorTicks

Specifies the number of minor tick marks for an axis

SetAxisNumericTicks

Specifies the ticks for a numeric axis

SetAxisTicks

Specifies positions and labels for axis tick marks

SetAxisViewRange

Specifies the axis range

Table C.4 lists methods that draw lines, polygons, text, and other figures on a graph. The methods are provided by the Plot class. See Chapter 9, "Drawing on Graphs."

Table C.4. Methods Associated with Drawing on Graphs

Category/Method

Description

DEFINE COORDINATES

DrawSetRegion

Specifies the drawing regions: PLOTBACKGROUND, PLOT-FOREGROUND, or GRAPHFOREGROUND

DrawUseDataCoordinates

Specifies that objects are to be drawn in the coordinate system defined by the data

DrawUseNormalizedCoordinates

Specifies a coordinate system for a graph that is independent of the data

SET PROPERTIES

DrawSetPenAttributes

Specifies the color, style, and width of a graphical pen in a single call

DrawSetPenColor

Specifies the color of the graphical pen. Valid values include predefined integers such as RED and BLACK, and hexadecimal values such as 04169E1x.

DrawSetPenStyle

Specifies the style of the graphical pen. Valid values are OFF, SOLID, DASHED, DOTTED, DASHDOT, and DASHDOTDOT.

DrawSetPenWidth

Specifies the width of the graphical pen. Typical values are 1-5.

DrawSetBrushColor

Specifies the color of the graphical brush. The brush is used to fill the interior of polygons, arcs, and markers.

DrawSetTextAlignment

Specifies the text alignment for subsequent DrawText commands. Valid values for horizontal alignment are ALIGN_LEFT, ALIGN_CENTER, and ALIGN_RIGHT. Valid values for vertical alignment are ALIGN_BOTTOM, ALIGN_BASELINE, ALIGN_CENTER, and ALIGN_TOP.

DRAW FIGURES

DrawLine

Draws a line or polyline

DrawMarker

Draws markers

DrawPolygon

Draws a polygon

Draws a rectangle

DrawRectangle

DrawText

Draws text

ANIMATION

DrawBeginBlock

Defines the beginning of a named set of drawing statements

DrawEnableAutoUpdate

Specifies whether each drawing command should cause the plot to redraw itself

DrawEndBlock

Defines the end of a named set of drawing statements

DrawRemoveCommands

Deletes a named set of drawing statements along with any figures that were drawn by those statements

Table C.5 lists other frequently used methods. Except for the SetGraphAreaMargins method (which is defined in the Plot2D class), these methods are all in the Plot class.

Table C.5. Frequently Used Methods in the Plot Class

Method

Description

CopyToOutputDocument

Copies a static image of a plot to the output window

GetVars

Gets the names of the variables in a graph that have a specified role

SetGraphAreaMargins

Specifies the amount of space between the plot area and the edge of the window

SetMarkerSize

Specifies the size of the marker that represents an observation in a graph

SetObsLabelVar

Specifies a variable that labels observations in a graph

SetPlotAreaMargins

Specifies the amount of space between the data and the edge of the plot area

SetTitleText

Specifies the title for a graph (often used with ShowTitle)

ShowObs

Specifies whether observations are always displayed or are displayed only when they are selected

ShowReferenceLines

Specifies whether a reference grid is displayed

ShowTitle

Specifies whether the title is visible

C.5 Methods for Creating and Modifying Plots

In addition to the methods in the DataView and Plot classes, each kind of graph has methods that create and modify the graph. This section presents frequently used methods for the plot types discussed in this book. You can view the complete set of methods for any IMLPlus class from the SAS/IML Studio online Help. Choose Help C.5 Methods for Creating and Modifying Plots Help Topics and then expand the IMLPlus Class Reference section.

C.5.1 Bar Chart Methods

Table C.6 summarizes frequently used methods in the BarChart class. See Section 7.3 for details.

Table C.6. Frequently Used Methods in the BarChart Class

Method

Description

BarChart.Create

Creates a bar chart

SetOtherThreshold

Specifies a cutoff percentage for determining which categories are combined into a generic category called "Others"

ShowBarLabels

Shows or hides labels of the count or percentage for each category

ShowPercentage

Specifies whether the graph's vertical axis displays counts or percentages

C.5.2 Box Plot Methods

Table C.7 summarizes the frequently used methods in the BoxPlot class. See Section 7.7 for details.

Table C.7. Frequently Used Methods in the BoxPlot Class

Method

Description

BoxPlot.Create

Creates a bar chart

SetWhiskerLength

Specifies the length of the box plot whiskers as a multiple of the interquartile range

ShowMeanMarker

Specifies whether to overlay the mean and standard deviation on the box plot

ShowNotches

Specifies whether to display a notched box plot. This variation of the box plot indicates that medians of two box plots are significantly different at approximately the 0.05 significance level if the corresponding notches do not overlap.

C.5.3 Histogram Methods

Each graph type has methods that control the appearance of the graph. Table C.8 summarizes frequently used methods in the Histogram class. See Section 7.4 for details.

Table C.8. Frequently Used Methods in the Histogram Class

Method

Description

Histogram.Create

Creates a histogram

ReBin

Specifies the offset and width for the histogram bins

ShowBarLabels

Shows or hides labels of the count, percentage, or density for each category

ShowDensity

Specifies whether the graph's vertical axis displays counts or density

ShowPercentage

Specifies whether the graph's vertical axis displays counts or percentages

C.5.4 Line Plot Methods

Table C.9 summarizes frequently used methods in the LinePlot class. See Section 7.6 for details.

Table C.9. Frequently Used Methods in the LinePlot Class

Method

Description

LinePlot.Create

Creates a line plot with one or more Y variables

LinePlot.CreateWithGroup

Creates a line plot in which each line is determined by categories of a grouping variable

AddVar

Adds a new Y variable to an existing line plot

ConnectPoints

Specifies whether to connect observations for each line

SetLineAttributes

Specifies the color, style, and width of a line

SetLineColor

Specifies the color of a line

SetLineStyle

Specifies the style of a line

SetLineWidth

Specifies the width of a line

SetLineMarkerShape

Specifies the marker shape for a line

ShowPoints

Specifies whether to show the markers for a line

C.5.5 Scatter Plot Methods

Except for ScatterPlot.Create method, the ScatterPlot class does not contain any frequently used methods.

C.6 Calling SAS Procedures

You can call any SAS procedure, DATA step, or macro from within an IMLPlus program. Simply enclose the SAS statements between the SUBMIT and ENDSUBMIT statements, as shown in the following example:

submit;                                     /* begin SUBMIT block  */
data a;                                     /* run a DATA step     */
   do x = 1 to 10;
      y = x + rannor(1);
      output;
   end;
run;

proc reg data=a;                            /* run a procedure     */
   model y = x;
quit;
endsubmit;                                  /* end SUBMIT block    */

You can pass parameters into SUBMIT blocks as described in Section 4.4.

C.7 Calling R Functions

R is an open-source language and environment for statistical computing. You can call R functions from an IMLPlus program provided that you have installed a 32-bit Windows version of R on the same PC that runs SAS/IML Studio. Enclose the R statements between the SUBMIT and ENDSUBMIT statements. The SUBMIT statement must contain the R option, as shown in the following example:

submit / R;
lm(Height ~ Girth, data=trees)
endsubmit;

You can pass parameters into SUBMIT blocks as described in Section 4.4. The mechanism is the same for calling R functions as it is for executing SAS statements.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset