Truncated character comparisons
The relational expression in
if ( 'AB' = 'ABC' )
evaluates to False, since the shorter element is padded to the length of the longer. On the other hand,
if ( 'AB' =: 'ABC' )
is True—the colon after the equals sign tells SAS to truncate the longer element to the length of the shorter.This also works for other relational operators like > or <.
Three-way comparisons
When we want to see if some number (say, for example, b) has a value between two other numbers (say, a and c), in other languages we would usually have to write the equivalent of
if ( a < b ) and ( b < c )
This is a common enough form, and SAS gives us a short cut:
if ( a < b < c )
(This form can of course use other relational operators, such as <=, = , and so on.)
Short-cut accumulation
Here's another common form that we would have to write this way in most other languages:
a = a + b
Again, SAS gives us a short cut:
a + b
(This form also implies retain a 0, but it's usually better to specify RETAIN
explicitly. More on this later.)
The relational expression in
if ( 'AB' = 'ABC' )
evaluates to False, since the shorter element is padded to the length of the longer. On the other hand,
if ( 'AB' =: 'ABC' )
is True—the colon after the equals sign tells SAS to truncate the longer element to the length of the shorter.This also works for other relational operators like > or <.
Three-way comparisons
When we want to see if some number (say, for example, b) has a value between two other numbers (say, a and c), in other languages we would usually have to write the equivalent of
if ( a < b ) and ( b < c )
This is a common enough form, and SAS gives us a short cut:
if ( a < b < c )
(This form can of course use other relational operators, such as <=, = , and so on.)
Short-cut accumulation
Here's another common form that we would have to write this way in most other languages:
a = a + b
Again, SAS gives us a short cut:
a + b
(This form also implies retain a 0, but it's usually better to specify RETAIN
explicitly. More on this later.)
No comments:
Post a Comment