Some notes on SAS-IML

Source: S. Rathbun, class notes Environmental Statistics, Univ. of Georgia, Athens, Spring 1994

To help you understand the design of the SAS programs, a very short introduction on SAS-IML (SAS matrix language) is given here. Please consult your statistics or computing department library for detailed SAS documentation on IML.

Basically, a typical PROC IML program will consist of a main program plus one or more subroutines, followed by statements that input data into arrays and that initiate program execution. Note that each subroutine must precede any subroutine or main program that calls it! The following order of statements may form a PROC IML program:

PROC IML;

CREATE Sasdataset2 VAR{variables}

START Subroutine1;
.... Program statements ...;
FINISH;

START Subroutine2;
.... Program statements ...;
FINISH;

START Mainprogram;
RUN Subroutine1;
RUN Subroutine2;
.... Other Program statements ...;
FINISH;

USE Sasdataset1;
READ range VAR{variables} INTO array;

RUN Mainprogram;

The CREATE statement is optional and can be used to output the values of scalar variables by using an APPEND statement in either the main program or one of the subroutines. One or more sub-routines plus a main program can be included in PROC IML. Each of these begins with a START statement and ends with a FINISH statement. The main program and the subroutines may call a previously appearing subroutine using a RUN statement.

The USE statement is optional and tells IML which SAS data set is to be analyzed.

The READ statement reads data from the SAS data set into arrays appearing in the IML program.

The RUN statement at the very end of PROC IML invokes the actual execution of the main program and its subroutines. Note that the values of program parameters may be set between the READ statement and the RUN statement at the end of PROC IML.

[Back to E079-001]