Understanding the Interactive Matrix Language

CALL Statements and Subroutines

CALL statements invoke a subroutine to perform calculations, operations, or a service. CALL statements are often used in place of functions when the operation returns multiple results or, in some cases, no result. The general form of the CALL statement is as follows:

CALL SUBROUTINE arguments ;

where arguments can be matrix names, matrix literals, or expressions. If you specify several arguments, use commas to separate them. Also, when using arguments for output results, always use variable names rather than expressions or literals.

Creating Matrices with CALL Statements

Matrices are created whenever a CALL statement returns one or more result matrices. For example, the following statement returns two matrices (vectors), VAL and VEC, containing the eigenvalues and eigenvectors, respectively, of the symmetric matrix t:
  
    call eigen(val,vec,t);
 

You can program your own subroutine by using the START and FINISH statements to define a module. You can then execute the module with a CALL or RUN statement. For example, the following statements define a module named MYMOD that returns matrices containing the square root and log of each element of the argument matrix:

  
    start mymod(a,b,c); 
       a=sqrt(c); 
       b=log(c); 
    finish; 
    run mymod(s,l,x);
 
Execution of the module statements creates matrices s and l, containing the square roots and logs, respectively, of the elements of x.

Performing Services

You can use CALL statements to perform special services, such as managing SAS data sets or accessing the graphics system. For example, the following statement deletes the SAS data set named MYDATA:
  
    call delete(mydata);
 

The following statements activate the graphics system (CALL GSTART), open a new graphics segment (CALL GOPEN), produce a scatter plot of points (CALL GPOINT), and display the graph (CALL GSHOW):

  
    call gstart; 
    call gopen; 
    call gpoint(x,y); 
    call gshow;
 

Previous Page | Next Page | Top of Page