SAS is a procedural programming language. (So are FORTRAN and C.) SAS programming tends to be action-oriented. The procedure (or SAS/IML module) is the "unit" of programming. The procedure manipulates and analyzes the data.
In contrast, the IMLPlus programming language borrows ideas from object-oriented programming. An important idea in object-oriented programming is the concept of a class. A class is an abstract package of data and of functions (called methods) that query, retrieve, or manipulate the data.
An object
is a concrete realization (or instance) of a class. To create an object, you need to specify the data to the creation routine for the class. To call methods in
IMLPlus, you use a "dot notation"
syntax in which the method name is appended to the name of the object. The form of the syntax is Object.Method(arguments)
, as shown in the following examples.
In the SAS/IML language, all variables are matrices. In IMLPlus, a variable is implicitly assumed to be a SAS/IML matrix unless the variable is declared to refer to an object. You can specify that an IMLPlus variable refers to an object by using the declare keyword.
For example, to create a variable named dobj
that refers to an object of the DataObject class, you can use the CreateFromFile method
of the class:
declare DataObject dobj; dobj = DataObject.CreateFromFile("Hurricanes"); dobj.Sort( "latitude" );
The dobj
object is declared in the first line, created in the second, and manipulated in the third by calling a method. The Sort
method sorts the data in dobj
by the latitude
variable. The data set on disk is not affected; it was used only to create the initial instance of the object.
To simplify the discussion, the remainder of this document refers to objects by the name of their class. Thus a DataObject object is called merely a "DataObject" instead of an "instance of the DataObject class."
Note: SAS/IML statements are not case-sensitive.
That is, if you define a matrix named MyMatrix
, you can refer to the matrix as mymatrix
, MyMaTrIx
, or any other combination of uppercase and lowercase letters. The names of IMLPlus classes and methods, however, are case-sensitive. There is no class named "dataobject" (lowercase), only "DataObject." There is no method in the DataObject
class named "sort," only "Sort" (capitalized).