@whymath ,
This particular trick? No. But even beginning programmers use logical expressions all the time. For example, consider:
if first.state then do;
There is no comparison there. First.state is either 1 or 0, and the software considers 1 to be true and 0 to be false. So there is no need for:
if first.state=1 then do;
Actually, the evaluation of logical expressions goes beyond 1 and 0. The software considers 0 and missing values to be false, and all other values (including negative numbers) to be true. So consider a simple statement:
a = b / c;
When c is 0, the software notes that division by zero took place, and tracks how many times it happened. It also runs up the bill, taking vastly more CPU time. Similarly, when c is missing, the result is that a missing value gets generated. Again, the software runs up the bill (CPU time, that is), with no usable numeric result. So if you have lots of missing values of zeros for C, it can be faster to use this statement:
if c then a = b / c;
The IF clause treats C as a logical expression (false for missings and zero, but true for all other values. So there is no attempt to calculate anything when C is missing or zero. I don't think I can come up with a realistic use for:
do i=1 to 5, j=5 to 7;
... View more