Chapter Contents

Previous

Next
SAS Language Reference: Dictionary

Syntax


Syntax of Functions

The syntax of a function is

function-name (argument-1<. . .,argument-n>)
function-name (OF variable-list)
function-name (OF array-name{*})
where

function-name
names the function.

argument
can be a variable name, constant, or any SAS expression, including another function. The number and kind of arguments allowed are described with individual functions. Multiple arguments are separated by a comma.
Tip: If the value of an argument is invalid (for example, missing or outside the prescribed range), SAS prints a note to the log indicating that the argument is invalid, sets _ERROR_ to 1, and sets the result to a missing value.
Examples:

  • x=max(cash,credit);

  • x=sqrt(1500);

  • NewCity=left(upcase(City));

  • x=min(YearTemperature-July,YearTemperature-Dec);

  • s=repeat('----+',16);

  • x=min((enroll-drop),(enroll-fail));

  • dollars=int(cash);

  • if sum(cash,credit)>1000 then
       put 'Goal reached';

(OF variable-list)
can be any form of a SAS variable list, including individual variable names. If more than one variable list appears, separate them with a space.
Examples:

  • a=sum(of x  y  z);

  • The following two examples are equivalent.

    • a=sum(of x1-x10 y1-y10 z1-z10);
      a=sum(of x1-x10, of y1-y10, of z1-z10);

  • z=sum(of y1-y10);

(OF array-name{*})
names a currently defined array. Specifying an array in this way causes SAS to treat the array as a list of the variables instead of processing only one element of the array at a time.
Examples:

  • array y{10} y1-y10;
    x=sum(of y{*});


Syntax of CALL Routines

The syntax of a CALL routine is

CALL routine-name (argument-1<. . .,argument-n>);

where

routine-name
names a SAS CALL routine.

argument
can be a variable name, a constant, any SAS expression, an external module name, an array reference, or a function. Multiple arguments are separated by a comma. The number and kind of arguments allowed are described with individual CALL routines in the dictionary section.
Examples:

  • call rxsubstr(rx,string,position);

  • call set(dsid);

  • call ranbin(Seed_1,n,p,X1);

  • call label(abc{j},lab);


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.