User:LainieH/test page

From sasCommunity
Jump to: navigation, search

sasCommunity Tip of the Day

x = 5+2*4; (is ambiguous.)
Do you mean: (5+2)*4;
Or do you mean: 5+(2*4);
 
What about: A or B and C;

A SAS expression with no more than one operator is called a simple expression. When an expression includes several operators, it is called a compound expression. When SAS encounters a compound expression, it follows certain rules to determine the order in which to evaluate each part of the expression. Knowing about this operator order, and how to use parentheses to alter it, can be crucial when writing compound expressions.

In the code to the right operator order determines whether X takes on the value of 13 or 28. These two IF statements are not equivalent and operator order and evaluation dictates the application of the logic. You are well advised to use parentheses.

Submitted by Art Carpenter. Contact me at my Discussion Page.



Feel free to comment on this tip.




Check out the Tip of the Day page for details about this effort.



View the web-site usage statistics and the definition of terms used in that report.