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
]
You can invoke INSIGHT three different ways:
- Issue an
INSIGHT command from a Display Manager command box, e.g.:
INSIGHT TOOLS
- 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.
- 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
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:
-
Most of the actions in SAS/INSIGHT use a noun-verb syntax. That is,
you first select an object (noun), then choose a menu (verb). For example,
to produce a scatterplot matrix, select two or more variables (nouns), then
select Scatter Plot (Y X) from the Analyze menu. The scatterplot
is produced automatically.
-
If no variables are selected, then Scatter Plot (Y X)
brings up a panel where you can choose the Y variable(s) and X
variable(s) from those in the data table. This is often a more
flexible way to make plots and do analyses.
-
To select one object, click on the object. This selects the object,
and deselects all other objects.
-
To extend or toggle a selection, Ctrl-click on the object. This selects a
deselected object, or deselects a selected object.
to
-
To select a group of objects, press the mouse button down, drag the
mouse, then release the mouse button. In graphs, this creates a
brush that you can size and move to highlight observations in linked
plots.
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:
- Drag a corner of the window outward to make the window bigger.
- Go to the Tools window and click on the magnifying glass.
- 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.
- 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.
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.
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:
- As described above (Starting SAS/INSIGHT)
When you start SAS/INSIGHT with a PROC INSIGHT statement,
you must terminate INSIGHT before you
can run additional procedures from the Program Manager.
- If you do not supply an OUT= name, the new data set is called
_paint_.
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>
SAS Guides Menu.