Using SAS/INSIGHT

Here are some excellent SAS/INSIGHT tips, edited and extended from the documentation for Warren Sarle's %TNN neural net macro.
[ Starting SAS/INSIGHT | Working with SAS/INSIGHT objects | Saving your preferences | Other INSIGHTful features ]

Starting SAS/INSIGHT

You can invoke INSIGHT three different ways:
  1. Issue an INSIGHT command from a Display Manager command box, e.g.:
    INSIGHT TOOLS
    
  2. Select Solutions:Analysis:Interactive Data Analysis from the menus. After you have opened a data set, select Edit:Windows:Tools from the menu to bring up the tools window.
  3. Submit a PROC INSIGHT statement, e.g.:
    PROC INSIGHT TOOLS; RUN;
    
If you run INSIGHT as a procedure (i.e., with the PROC INSIGHT statement), you must terminate INSIGHT before you can run additional procedures. If you would prefer to leave INSIGHT active while you are running various other procedures or DATA steps, invoke INSIGHT from the Display Manager menus or command line instead of by submitting a PROC INSIGHT statement.

Selecting a dataset

INSIGHT works on SAS datasets stored in a library (directory) which must be defined before you start an INSIGHT session. The WORK and SASUSER libraries are always predefined, so any datasets you have created in your SAS session are available. Other, course-specific libraries (e.g., PSY303, PSY614) may also be available, or you may have to submit a LIBNAME statement to define the library before you start INSIGHT.

When you start INSIGHT, an Open panel appears. You should first select a data library, then select a data set from the scrolling list, and click the Open button. (You can also enter a new dataset in the spreadsheet data editor by selecting the New button).

Alternatively, you can specify a dataset directly in the INSIGHT command or in the PROC INSIGHT statement, e.g.,

INSIGHT TOOLS DATA=PSY614.BASEBALL

Working with SAS/INSIGHT objects

If you are not familiar with the SAS/INSIGHT product, browse through the menus and the HELP system, and then click on lots of things in the windows to see what happens. As a last resort, you can even RTFM. If you are not familiar with point-and-click interfaces, keep the following guidelines in mind:

The default white background with Version 6.10 often makes the plots difficult to see, especially if you are using colors. To change the background to black, choose Edit:Windows:Display Options... from the menu, click on the "Black" button under "Background", and click on "OK".

You may want to make a plot or plots bigger. To do so, you can follow these steps:

  1. Drag a corner of the window outward to make the window bigger.
  2. Go to the Tools window and click on the magnifying glass.
  3. Go back to the window containing the plot(s) you want to make bigger and click near (but not too near) the edge of the window. The plot(s) should grow to fill most of the window.
  4. Go to the Tools window and click on the arrow to restore the usual mouse cursor.
You can also drag the corner of an individual plot to make it bigger or smaller. The method described above will enlarge all of the plots in a window without disturbing their alignment.

Saving your preferences

To save the setting of the background color or various other INSIGHT options so that they will become the default settings for subsequent invocations of INSIGHT, choose File:Save:Options from the menu.

Other INSIGHTful features

Animated Graphs

You can animate the selection of observations either in one graph, or in all graphs simultaneously.

Choose Windows:Animate from the Edit menu. The Animate dialog box allows you to choose one variable which controls the animation. As the values of this variable change (after you click Apply), the observations having this value are selected both in the graph and in the data window when you click Apply. A slider controls the speed of cycling through the possible values.

Showing groups by color or marker shape

If you have the Tool bar showing (i.e., you started with insight tools and observations are selected in any window, clicking on one of the color or marker shapes in the Tool bar assigns the selected points that color or shape. [Use Edit:Windows:Tools to raise the Tool bar if you started without it.]

Note that this is particularly effective together with the Animate window -- click on a value of the group variable, and all observations with that value are selected. Change the color or marker shape as above.

Alternatively, you can click on the 'rainbow' button or the 'all markers' button to bring up a window that will allow you to set the colors or markers according to the values of any variable.

%paint-ing observations

The color/marker selection described above is handy for discrete variables with a few distinct values, but tedious to do if there are many values of a grouping variable.

The %paint macro (by Warrne Kuhfeld) reads an input DATA= data set and creates an OUT= data set with a new variable _OBSTAT_ that contains observation symbols and colors interpolated from the COLORS= list based on the values VAR= variable.

The _OBSTAT_ variable is interpreted specially by INSIGHT to assign colors and shapes to individual observations. Three interpolation methods (NOMINAL, ORDINAL, INTERVAL) are available with the LEVEL= option.

For example, the statements below choose the color of observations based on the YEARS variable. Values 1 or less (rookies) are painted red, values 7 or more are painted blue, values in between map to colors between red and blue.

%paint(data=psy614.baseball, out=basenew,
	var=years,
	colors= red blue   1 7);

proc insight tools data=basenew;
run;
Notes:

BY-variables

Most Analysis and Graph options allow a Group variable. When you assign a variable to the group role, a stratified analysis or plot is done -- one for each value of the group variable, similar to the function of the BY statement in SAS procedures.

You can assign a variable as a Group variable by default by clicking in the small box above the variable's name in the datasheet.

INSIGHTful statements

Most of the things you can do manually you can also do with programming statements. For example, to produce a scatterplot matrix of SALARY, YEARS and HITS in the Baseball data, and fit a regression model predicting salary, you could type:
proc insight tools data=psy614.baseball;
	scatter salary years hits * salary years hits / label=name;
	fit salary = years hits;
	run;
You can also record your SAS/INSIGHT session in the form of statements you can replay later to redo a set of steps. Choose File:Save:Statements and the equivalent SAS statements are recorded to the SAS log window. (Some actions -- like transforming variables or excluding certain observations are not recorded, however.)

If you start INSIGHT with the FILE= option,

insight tools file='a:\myins.sas'
the recorded statements are recorded to the named file.

Prepared by Michael Friendly
Email<friendly@yorku.ca>

[Back] SAS Guides Menu.