Previous Page | Next Page

Macro Statements

%SYSCALL Statement

Invokes a SAS call routine.
Type: Macro statement
Restriction: Allowed in macro definitions or in open code
See also: %SYSFUNC and %QSYSFUNC Functions

Using the RANUNI Call Routine with %SYSCALL


%SYSCALL call-routine<(call-routine-argument-1 <>)>;


is a SAS or user-written CALL routine created with SAS/TOOLKIT software or a routine created using the FCMP procedure. All SAS call routines are accessible with %SYSCALL except LABEL, VNAME, SYMPUT, and EXECUTE.

call-routine-argument-1 <>

is one or more macro variable names (with no leading ampersands), separated by commas. You can use a text expression to generate part or all of the CALL routine arguments.


When %SYSCALL invokes a CALL routine, the value of each macro variable argument is retrieved and passed unresolved to the CALL routine. Upon completion of the CALL routine, the value for each argument is written back to the respective macro variable. If %SYSCALL encounters an error condition, the execution of the CALL routine terminates without updating the macro variable values, an error message is written to the log, and macro processing continues.

Note:   The arguments to %SYSCALL are evaluated according to the rules of the SAS macro language. This includes both the function name and the argument list to the function. In particular, an empty argument position will not generate a NULL argument, but a zero length argument.  [cautionend]

Do not use leading ampersands on macro variable names.

The arguments in the CALL routine invoked by the %SYSCALL macro are resolved before execution. If you use leading ampersands, then the values of the macro variables are passed to the CALL routine rather than the names of the macro variables.  [cautionend]

Macro variables contain only character data.

When an argument to a function might be either numeric data or character data, %SYSCALL attempts to convert the supplied data to numeric data. This causes truncation of any trailing blanks if the data was character data. %SYSCALL does not modify arguments that might be character data.

You can preserve the trailing blanks by using the %QUOTE function when assigning the value to the macro variable that will be supplied as the argument to the function. To determine whether it is necessary to preserve the trailing blanks using the %QUOTE function, consult the documentation for the desired function to see whether the arguments are numeric only, character only, or either numeric or character. Use the %QUOTE function to quote the value supplied to arguments that are documented to be either numeric or character.  [cautionend]


Example 1: Using the RANUNI Call Routine with %SYSCALL

This example illustrates the %SYSCALL statement. The macro statement %SYSCALL RANUNI(A,B) invokes the SAS CALL routine RANUNI.

Note:   The syntax for RANUNI is RANUNI(seed,x).  [cautionend]

%let a = 123456;
%let b = 0;
%syscall ranuni(a,b);
%put &a, &b;

The %PUT statement writes the following values of the macro variables A and B to the SAS log:

1587033266 0.739019954

Previous Page | Next Page | Top of Page