Syntax, %SYSFUNC function:
%SYSFUNC(function(argument-1<...argument-n>)<,format>)
function
is the name of the
function to execute. This function can be a SAS function, a function
written with SAS/TOOLKIT software, or a function created using the
FCMP procedure. The function cannot be a macro function.
argument
is one or more arguments
used by function. An argument
can be a macro variable reference or a text expression that produces
arguments for a function.
format
is an optional format
to apply to the result of function. There is no default value for
format. If you do not specify a format, the SAS macro facility does
not perform a format operation on the result and uses the default
of the function.
|
%let string=william SMITH; %put %sysfunc(propcase(&string));
William Smith
%let d=%eval(10+20); /* Correct usage */ %let d=%eval(10.0+20.0); /* Incorrect usage */
Syntax, %EVAL function:
%EVAL(arithmetic
or logical expression)
|
%let a=1+2; %let b=10*3; %let c=5/3; %let eval_a=%eval(&a); %let eval_b=%eval(&b); %let eval_c=%eval(&c); %put &a is &eval_a; %put &b is &eval_b; %put &c is &eval_c;
1+2 is 3 10*3 is 30 5/3 is 1
Syntax, %SYSEVALF function:
%SYSEVALF(expression<,conversion-type>)
expression
is an arithmetic or
logical expression to evaluate.
conversion-type
converts the value
returned by %SYSEVALF to the type of value specified. The value can
then be used in other expressions that require a value of that type.
Conversion-type can be one of the following:
BOOLEAN
returns
0 if
the result of the expression is 0 or missing. It returns 1 if
the result is any other value. CEIL
returns a character
value representing the smallest integer that is greater than or equal
to the result of the expression. If the result is within 10–12 of
an integer, the function returns a character value representing that
integer.
FLOOR
returns a character
value representing the largest integer that is less than or equal
to the result of the expression. If the result is within 10–12 of
an integer, the function returns that integer.
INTEGER
returns a character
value representing the integer portion of the result (truncates the
decimal portion). If the result of the expression is within 10–12 of
an integer, the function produces a character value representing that
integer. If the result of the expression is positive, INTEGER returns
the same result as FLOOR. If the result of the expression is negative,
INTEGER returns the same result as CEIL.
|
%macro figureit(a,b); %let y=%sysevalf(&a+&b); %put The result with SYSEVALF is: &y; %put The BOOLEAN value is: %sysevalf(&a +&b, boolean); %put The CEIL value is: %sysevalf(&a+&b, ceil); %put The FLOOR value is: %sysevalf(&a+&b, floor); %put The INTEGER value is: %sysevalf(&a+&b, int); %mend figureit; %figureit(100,1.597)
The result with SYSEVALF is: 101.597 The BOOLEAN value is: 1 The CEIL value is: 102 The FLOOR value is: 101 The INTEGER value is: 101