SAS/Insight

  1. Starting PROC INSIGHT

  2. Accessing the IRIS Data Set

  3. Using the Tools Menu

  4. Changing Plot Sizes

  5. Using the Windows Menu

  6. Entering Data into a New Insight Spreadsheet

    1. Creating New Variables Using the Insight Calculator

SAS/Insight is the data visualization and analysis component of the SAS System. It provides a set of the most commonly employed statistical tools within an easy to use and understandable interface. See also SAS/LAB (from the SAS Globals menu, select Analyze, and then select "Guided data analysis") for a menu driven interface which provides interpretations for statistical tests as well as an easy to use interface. This set of notes is designed for use with SAS 6.10 installed on a Macintosh or SAS 6.11 installed on a PC running an MS Windows environment (Windows 3.x, Windows 95, or Windows NT).

These class notes provide an introductory set of exercises to get you started using PROC INSIGHT. They are meant as a starting point only. You are encouraged to explore alternative menu options and data sets. A second objective is to show how Insight tools can not only help you to perform routine statistical analyses, but also, how you can use its visual tools to help understand statistical concepts.


Starting and Exiting from PROC INSIGHT

When using Insight, you will find it useful to have several Insight windows open simultaneously. Thus, it is recommended that you close down all non-essential applications prior to starting Insight. To begin SAS/Insight, first start SAS by double clicking on the SAS icon.

Prior to starting SAS/Insight, we will use the SAS LIBNAME command to associate library reference names (librefs) with existing SAS data libraries stored on our machines. The following procedure will provide access to sample data sets stored in the SAS/Insight sample data library as well as to the work, maps, sashelp, and sasuser data libraries:

Note: If you frequently use a data library, you can include the LIBNAME command in the file AUTOEXEC.SAS so that the library will be automatically associated with a library reference name each time you start the SAS System.

To start SAS/Insight, from the SAS Globals menu, select Analayze, and then select "Interactive data analysis". Alternatively, you can start Insight either by executing the following command in the Program Editor:

    PROC INSIGHT ;  RUN; 

Once you have started Insight, the "SAS/Insight: Open" dialog window will appear which allows you to select the data library and then a data set within the library to open.

A new spreadsheet can be created at any time by selecting New from the File menu; an existing spreadsheet can be accessed at a later time by selecting OPEN from the file menu. It is recommended that you periodically save your work as you enter data in a spreadsheet.

To Exit from Insight, click on the window close box, or from the Insight File menu, select End (alternatively, on a Mac, you can press ¤W; or from MS Windows, press the sequence "Alt+f e" or the sequence "Ctrl+F4"). To exit from the SAS System, from the File menu, select Quit (Mac alternative: ¤Q or PC alternatives, "Alt+f q"). Observe that available key short cuts are indicated on the pulldown menus of the SAS System.

Note: The "¤ key" notation is used to indicate Macintosh command key short cuts, i.e., ¤Q means press the Apple key (also known as the command or clover key), and, while it is depressed, press the W key. In the MS Windows environments, "Alt+f e" means press the Alt key, and while it is depressed, press the "f" key, release the Alt key and then press the "e" key. Likewise, "Ctrl+F4" is executed by pressing the Ctrl key and while it is depressed, pressing the "F4" key.


The Iris Data Set

We will use some graphical tools to examine the distribution of data values associated with variables in the IRIS data set (Fisher, R. A. 1936 "The Use of Multiple Measurements in Taxonomic Problems" Annals of Eugenics 7:179-188) provided in the Insight sample library. If you have not done so already, start SAS/Insight as described above; otherwise, from the File menu, select Open. The "SAS/Insight: Open" Window will appear. So as to be able to follow along in the following exercises, in the "Library:" field, select INSIGHT; in the "Data set:" field, select IRIS, and then select Open. A spreadsheet containing the Iris data set will appear.

Observe that this data set contains the following variables: Sepallen, Sepalwid, Petallen, Petalwid, and Species. There are fifty observations for each of the three species of iris: setosa, versicolor, and virginica.

In addition to the variable names at the head of each column, note that there are two blocks at the top of the column. The one to the right contains the abbreviation Int (Interval data) for the first three variables and Nom (Nominal or Character data) for the last variable species.

From the Insight pull down menu (the button in the upper left hand corner of the spreadsheet window containing a right pointing triangle), select "Define variables". A new window will appear. The rectangle in the upper left corner of the window contains the name of the current active data set, e.g., IRIS. Beneath this rectangle is a field containing a list of variables in the data set, one of which will be highlighted; the characteristics associated with this variable are displayed. These characteristics include Type, Measurement Level, Default Role, Name, and Label. If appropriate, the Type and Measurement Level can be change by clicking on the button corresponding to the appropriate characteristic. The default role is used to define how the variable can be used for analysis. We will define species as being a label variable: select species in the list of variable names and then click on the box in front of Label under the heading "Default Role"; a check mark will appear in this box. You can cahnge the name of a variable or its label by clicking on the line to the right, deleting the existing text, and then typing in the corrected information. Select OK when you have finished changing the characteristics for Species. Observe that the word "Label" now appears in the button to the left at the top of the Species column.

We can use Insight to sort the data by any of the variables in the data set. To sort alpabetically by species, and then by Sepal width within each species, complete the following steps. From the Insight pull down menu (right pointing triangle), select Sort. The Sort dialog window will open. From the list of variables, select Species and then click on the Y button; then select Sepalwid and click on Y; click on OK.

Displaying a Rotating Plot

From the Analyze menu, select "Rotating Plot (Z Y X)". The "Rotating Plot (Z Y X)" Dialog Window is displayed. From the list of variables, click on Sepallen and then click on Z, select Petalwid and click on Y, click on Petallen and click on X, and then click on OK. A plot of these variables in 3-D space is now displayed. You can use the "arrow" icons along the upper left edge of the window to rotate the plot. If you click on a point within the plot, the observation number corresponding to this point will be displayed.

Changing Plot Sizes

You can use the size box in the lower right hand corner of the plot window to increase the size of the window. To increase the size of the plot within the window, click on the lower right hand corner of the plot and then drag the corner marker to increase the plot to the size you desire.

Enhancing the Plot Display Using the Tools Window

We can use the Tools window to associate symbols or colors with points in the plots. From the Edit menu, select Windows, and then select Tools to display the Tools window. We will now associate different shaped and colored markers with each species of the Iris data set. In the bottom left corner of the Tools window, click on the "multiple Markers" button (the rectangular button below the individual marker buttons which contains minuature version of each of the symbols) to display the "Mark Observations" dialog window. Select Species and then click on OK. Observe that a different symbol is now associated with each species in the first column of the INSIGHT.IRIS spreadsheet window. Likewise we can associate a different color with each species; below the color chips is the "Multiple Colors" button (a rectangular button containing a gradient from black to red). Click on this button and the "Color Observations" window will appear. Select Species and then OK to assign a different color to each species.

It is also possible to associate a particular color or symbol with a selected group of observations. Say we wished to associate the color green with the species virginica: click on the green color chip in the tools menu. An expanded version of the "Color Observatons" appears. Select "Species" from the list of variables, "=" (equal) from the field labeld tests, "Virginica" from the list of values, and then select OK. The symbols can be changed in a similar fashion if desired. The symbols and colors will then be used whenever individual observations from the data set are displayed.

It is also possible to select observations from a data set and observe where they appear on a plot. For example, while in the Iris spreadsheet window, move the mouse pointer to the column containing the observation numbers and click on an observation. To select more than one observation, press the Ctrl key (PC) or Apple key (Macintosh) and while this key is depressed, click on the additional observation numbers or drag the mouse cursor over the desired observation numbers. To associate a new color (or marker) with the currently selected observations, click on the desired color chip (marker) in the Tools window.

By default, the mouse pointer is used to select items on the screen. The Hand tool can be used to modify plot displays. In the Rotating plot environment, depresing the (left) mouse button and dragging within the plot window will enable you to turn the plot in the direction of the drag. With the hand tool active, depressing the mouse button while keeping the mouse stationary will cause the plot to spin relative to the position the cursor; the further the cursor is placed from the origin of the spin axes, the faster the plot will spin.

The Magnifying Glass tool can be used to enlarge the size of the image within the plot window. Click on the magnifying glass tool and then click one or more times in the plot window to zoom in on the plot; click on this tool again and then click one or more times in the plot window to zoom back out.

To restore the normal (default) mouse cursor, from the Tools menu, select the Arrow tool.

Using the Windows Menu

It is good practice to Save (¤S) your work to files when you complete each analysis and close the associated window, but it is often desirable to keep a window open to compare its contents with the results of a subsequent analysis. The Windows menu provides a mechanism for keeping track of and switching between open windows. Each of the currently open windows is listed in this menu. You can bring a window to the foreground by selecting its name from this list. Thus you can bring the INSIGHT.IRIS spreadsheet window to the foreground by selecting it from the windows menu. Likewise you can access the Program Editor, Output, or Log Window by clicking on its name from among the list of choices in the Windows menu.

Another way to switch between open windows is to selectively place and size them on the screen such that a part of each window is displayed on the screen at all times. You can then move between windows by simply clicking on visible portion of the window of interest.


Entering Data into a New Insight Spreadsheet

If you have not done so already, start PROC INSIGHT as described above. The "SAS/Insight: Open" dialog window will appear which allows you to select the data library and then a data set within the library to open. To create a new data set, first select the library where you would like to create the data set (e.g., WORK), and then click on the New button at the bottom of the screen.

The spreadsheet window will appear. Click the mouse in a cell and you can now enter data. Press the Tab key to move right to the next cell, press Shift+Tab to move left, or press the Enter key to move down to the next cell. The arrow keys can also be used to navigate the spreadsheet; press the Enter key prior to using the left and right arrow keys to move between cells as otherwise their function is to position the cursor within the current cell. As an exercise, we will create a 3x3 array in this spread sheet. Enter the values 1, 2, and 3 in the first three cells of the first row; 4, 5, and 6 in the first three cells of the second row, and 7 & 8 in the first two cells of the third row leaving the third cell empty.

Creating New Variables Using the Transformation Window

Simple (single variable, two variable, or up to two variables and two constant) transformations can also be used to create new variables within the spreadsheet using the Variables option of the Edit menu. For example, the create a variable AB which is the product of A and B, from the Edit menu, select Variables, and then select Other. The "Edit Variables" dialog window will appear. In the field listing the variable names A, B, and C, click on A, and then on Y. Likewise click on B and then on X. In the transformation field, select "Y*X". By default, this variable will be called M_A; to change this to AB, click on the line to the right of "Name:", delete the current name, and then type in AB. Observe that the character string "A*B" is assigned to the Label. If you wish, you can change this as you had change the value of the variable name. Since the fields "a:" and "b:" are not used in the above tansformation, they can be left unchanged; if you use a transformation which employs these fields, e.g., "a+b*y", change the values for these values as appropriate. When all fields are correct, select OK. A new column labeled "AB" will be added to the spread sheet and contain the product of the values of the cells in the first two columns. Repeat for variables A and C; if you had left the third cell in row three empty, you will observe that the cell in the last row of the new variable will contain a dot (.) or missing value as SAS/Insight could not compute a valid value for this cell.


Client Systems Development and Support
Virginia Tech Computing Center

Last updated: December 11, 1997