I am working on a presentation of the Select statement vs. if-then/else conditional logic, and I am trying to find a paper or explanation of how SAS processes if-then logic differently than the select statement. If anyone knows of a good SUGI paper or another explanation online, that would be great.
Otherwise, here's the gist of what I'm comparing.
Compare these two examples.
when (1) flag = 1;
when (2) flag = 2;
otherwise flag = 3;
end; * end select;
if var = 1 then flag = 1;
else if var = 2 then flag = 2;
else flag = 3;
My understanding of the second example is that SAS will process line by line, checking first if var = 1, then cycling to the top and looking for var = 2, then setting setting flag = 3 for all other lines.
I have read from SAS that the select statement can be faster than if-then/else logic, so I'm wondering if anyone can explain how SAS processes the select statement differently than using if-then logic.