With the original dataset HAVE the grouping in the "data want1" and "data want2" steps is the same because variables a and x change their values in exactly the same observations. After sorting HAVE by x, however, the two formerly separated BY groups with a='A' and a='D' form a single BY group with respect to variable x (four consecutive observations with x=2). Hence the "data want2" step would select only one observation (with y=24) from that new group, not two (y=22, y=24) as before.
So, if the original grouping is what you want, but no variable like a exists, then you're in a situation where the NOTSORTED option (applied to x) comes to the rescue.
... View more