You can modify the UserAnalysis module to call your own analyses from the
→ menu item.To create your own UserAnalysis module:
Copy the UserAnalysis.sxs file distributed with SAS/IML Studio to your personal modules directory. The UserAnalysis.sxs file
is distributed in the Modules\System
subdirectory of the SAS/IML Studio installation directory. Your personal modules directory is usually the Modules
subdirectory of your personal files directory. (See the The Personal Files Directory section in Chapter 34 for more information about the personal files directory.)
Edit your personal copy of the UserAnalysis.sxs file. Modify the body of the UserAnalysis module so that it performs an analysis of your choosing.
Save the file.
Select
→ to store the module.Open any data set, and select
→ to run the module.
The UserAnalysis module must take a DataObject variable as its single argument. When you select
→ , the module is called. The currently active DataObject is used as the argument to the module.Table 33.1 lists a few of the methods in the DataObject class. You might find these methods useful in writing your analyses. These and other IMLPlus class methods are documented in the SAS/IML Studio online Help, in the “DataObject” section of the “IMLPlus Class Reference” chapter.
Table 33.1: Frequently Used DataObject Methods
Method |
Description |
---|---|
Adds a new variable to the DataObject. |
|
Returns the number of observations in the DataObject. |
|
Gets the index of observations selected in the DataObject. |
|
Gets the names of variables selected in the DataObject. |
|
Gets the data for a variable in the DataObject. |
|
Returns true if the named variable is nominal. |
|
Returns true if the named variable is numeric. |
|
Selects observations in the DataObject. |
|
Sets the color of observation markers. |
|
Sets the shape of observation markers. |
For example, you could modify the body of the UserAnalysis module to include the following statements. If you select a nominal variable from a data table and then select
→ , these statements assign a distinct marker shape to each unique value of the nominal variable. (If there are more unique values than marker shapes, the shapes are reused.) The NCOL, UNIQUE, LOC, and MOD functions are all part of the SAS/IML language, as are the IF and DO statements.start UserAnalysis(DataObject dobj); dobj.GetSelectedVarNames(VarName); /* get selected var name */ if ncol(VarName) = 0 then return; /* return if no selected variable */ if dobj.IsNominal(VarName) then do;/* if it is nominal... */ shapes = MARKER_SQUARE || MARKER_PLUS || MARKER_CIRCLE || MARKER_DIAMOND ||MARKER_X || MARKER_TRIANGLE || MARKER_INVTRIANGLE || MARKER_STAR; dobj.GetVarData(VarName, x); /* get the data */ ux = unique(x); /* find the unique values */ do i = 1 to ncol(ux); /* for each unique value... */ idx = loc(x = ux[<i]); /* find obs with that value */ iShape = 1 + mod(i-1, 8); /* choose next shape (mod 8) */ /* set the shape of the relevant observations */ dobj.SetMarkerShape(idx, shapes[iShape]); end; end; finish; store module=UserAnalysis;