Humbly, let's observe the initial thread question. Here's the first sentence from the OP:
"If I have a dataset with variables a and b and I sort by a then b how do I filter for the last entry of b for each a. "
Of course, I presume that he wants the "last entry" of each B variable value captured for output (which would be the default, since he didn't mention DESCENDING B as a sort criteria specification), with each A variable value (also a contributing "break" variable by definition). The SAS variable B is mentioned as a contributing data-variable to the sort order.
Again, with your second data-set as a decent sample to demonstrate the importance of testing IF LAST.B; , you will either get:
- four output observations: one obs for each unique A variable value and unique B variable value.
- two observations: one for each unique A variable value - oh, by the way, the value of B will be whatever occurred on the last/highest observation of A.
Clearly, data dependent, but the lack of testing: IF LAST.B; could yield incomplete output data.
If you believe that there should only be 2 observations - but the important point here is the need to have a "break" test (for output/filter) selection that includes variable B as well as variable A. That is where we have a difference of technical opinion, I believe.
Scott Barry
SBBWorks, Inc.