IF State = "Alabama" "AL" ELSE IF State = "Alaska" "AK" ELSE IF State = "Arizona" "AZ" ELSE IF State = "Arkansas" "AR" ELSE IF State = "California" "CA" ELSE IF State = "Colorado" "CO" ELSE IF State = "Connecticut" "CT" ELSE IF State = "Delaware" "DE" ELSE IF State = "Florida" "FL" ELSE IF State = "Georgia" "GA" ELSE IF State = "Hawaii" "HI" ELSE IF State = "Idaho" "ID" ELSE IF State = "Illinois" "IL" ELSE IF State = "Indiana" "ID" ELSE IF State = "Iowa" "IA" ELSE IF State = "Kansas" "KS" ELSE IF State = "Kentucky" "KY" ELSE IF State = "Louisiana" "LA" ELSE IF State = "Maine" "ME" ELSE IF State = "Maryland" "MD" ELSE IF State = "Massachusetts" "MA" ELSE IF State = "Michigan" "MI" ELSE IF State = "Minnesota" "MN" ELSE IF State = "Mississippi" "MS" ELSE IF State = "Missouri" "MO" ELSE IF State = "Montana" "MT" ELSE IF State = "Nebraska" "NE" ELSE IF State = "Nevada" "NV" ELSE IF State = "New Hampshire" "NH" ELSE IF State = "New Jersey" "NJ" ELSE IF State = "New Mexico" "NM" ELSE IF State = "New York" "NY" ELSE IF State = "North Carolina" "NC" ELSE IF State = "North Dakota" "ND" ELSE IF State = "Ohio" "OH" ELSE IF State = "Oklahoma" "OK" ELSE IF State = "Oregon" "OR" ELSE IF State = "Pennsylvania" "PA" ELSE IF State = "Rhode Island" "RI" ELSE IF State = "South Carolina" "SC" ELSE IF State = "South Dakota" "SD" ELSE IF State = "Tennessee" "TN" ELSE IF State = "Texas" "TX" ELSE IF State = "Utah" "UT" ELSE IF State = "Vermont" "VT" ELSE IF State = "Virginia" "VA" ELSE IF State = "Washington" "WA" ELSE IF State = "West Virginia" "WV" ELSE IF State = "Wisconsin" "WI" ELSE IF State = "Wyoming" "WY" ELSE State END IF
This computation looks at the variable State (it can be a text or a multiple-choice variable) for a recognizable state name. If it locates one, it will return the proper two-letter state abbreviation for the state. Otherwise it will return the contents of State.
NOTE: By far the easiest way to go from state name to state abbreviation (or vice versa) is to use a multiple choice variable. Use either the state name or the state abbreviation as the multiple choice option text and the other as a merge text value. See Computation #0054: Referencing Multiple Choice Merge Text.