Creates switch statement for selected variable