The FCMP Procedure |
SUBROUTINE subroutine-name (argument-1, ...,
argument-n) <VARARGS> <KIND | GROUP='string'>;
|
Arguments |
specifies the name of a subroutine.
specifies one or more arguments for the subroutine. Character arguments are specified by placing a dollar sign ($) after the argument name. In the following example,
subroutine mysub(arg1, arg2 $, arg3, arg4 $);arg1 and arg3 are numeric arguments, and arg2 and arg4 are character arguments.
specifies that the subroutine supports a variable number of arguments. If you specify VARARGS, then the last argument in the subroutine must be an array.
specifies arguments from the argument list that the subroutine should update.
specifies a collection of items that have specific attributes.
specifies arguments from the argument list that you want the subroutine to update.
Details |
The SUBROUTINE statement enables you to declare (create) an independent computational block of code that you can call with a CALL statement. The definition of a subroutine begins with the SUBROUTINE statement and ends with an ENDSUB statement. You can use the OUTARGS statement in a SUBROUTINE statement to specify arguments from the argument list that the subroutine should update.
Examples |
The following is an example of the SUBROUTINE statement:
proc fcmp outlib=sasuser.funcs.temp; subroutine inverse(in, inv) group="generic"; outargs inv; if in=0 then inv=.; else inv=1/in; endsub; options cmplib=sasuser.funcs; data _null_; x = 5; call inverse(x, y); put x= y=; run;
SAS writes the following output to the log:
x=5 y=0.2
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.