Tag Archives: switch

How to use a SWITCH Statement in SAS

In SAS, the switch statement is called a SELECT statement. SELECT <variable | expression>   WHEN(condition) …   <WHEN(condition) …>   <WHEN(condition) …>   …   <OTHERWISE …> END; http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm When a select expression is given, it evaluates this and does a relative jump, which is similar to the optimization done by a C or Java compiler in a switch […]

New in Java 7: switch()ing on Strings

Finally, Java can switch on Strings! No more inefficient strings of if/else chains or Hash lookups or translation into Enums. Finally just clean readable and intuitive code. switch(suit) { case “club”: case “diamond”: trickValue = 20; break; case “heart”: case “spade”: trickValue = 30; break; case “no-trump”: trickValue = 40; break; } It’s actually just […]