Chapter Contents |
Previous |
Next |
%SYSEVALF |
Type: | Macro function |
See also: | %EVAL |
Syntax | |
Details | |
Comparisons | |
Example | |
Illustrating Floating-Point Evaluation |
Syntax |
%SYSEVALF(expression<,conversion-type>) |
0 if the result of the expression is 0 or missing | |
1 if the result is any other value. |
For example,
%sysevalf(1/3,boolean) /* returns 1 */ %sysevalf(10+.,boolean) /* returns 0 */
%sysevalf(1 + 1.1,ceil) /* returns 3 */ %sysevalf(-1 -2.4,ceil) /* returns -3 */ %sysevalf(-1 + 1.e-11,ceil) /* returns -1 */ %sysevalf(10+.) /* returns . */
%sysevalf(-2.4,floor) /* returns -3 */ %sysevalf(3,floor) /* returns 3 */ %sysevalf(1.-1.e-13,floor) /* returns 1 */ %sysevalf(.,floor) /* returns . */
%put %sysevalf(2.1,integer); /* returns 2 */ %put %sysevalf(-2.4,integer); /* returns -2 */ %put %sysevalf(3,integer); /* returns 3 */ %put %sysevalf(-1.6,integer); /* returns -1 */ %put %sysevalf(1.-1.e-13,integer); /* returns 1 */
Details |
The %SYSEVALF function performs floating-point arithmetic and returns a value that is formatted using the BEST32. format. The result of the evaluation is always text. %SYSEVALF is the only macro function that can evaluate logical expressions that contain floating point or missing values. Specifying a conversion type can prevent problems when %SYSEVALF returns missing or floating point values to macro expressions or macro variables that are used in other macro expressions that require an integer value.
For details on evaluation of expressions by the SAS macro language, see Chapter 6 in SAS Macro Language: Reference.
Comparisons |
Example |
The macro FIGUREIT performs all types of conversions for SYSEVALF values.
%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)
Executing this program writes these lines to the SAS log:
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
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.