Creates a switch statement for the selected variable.