I need to categorise a variable based on certain values. I want, however, that it is done sequentially and that the last value trumps the previous "if" statements. data hhdata; set hhdata; if '5.1b'n = 0 or '5.1b'n = 1 then FoodSecurity = "Food Secure"; If (('5.1b'n in (2 3)) or ('5.2b'n in (1 2 3)) or ('5.3b'n = 1 or '5.4b'n = 1)) then FoodSecurity = "Mildly Food Insecure Access"; If '5.3b'n = 2 or '5.3b'n = 3 or '5.4b'n = 2 or '5.4b'n = 3 or '5.5b'n = 1 or '5.5b'n = 2 or '5.6b'n = 1 or '5.6b'n = 2 then FoodSecurity = "Moderate Food Insecure Access"; If (cat(of '5.7b'n--'5.9b'n) in (1 2 3)) then FoodSecurity = "Severe Food Insecure Access"; else if '5.5b'n = 3 or '5.6b'n = 3 then FoodSecurity = "Severe Food Insecure Access"; if '5.1b'n in ('-' ' ') or cat(of '5.2b'n--'5.9b'n) in ('-' ' ') then FoodSecurity = "Missing"; run; Lines 3, 10, and 12 should be "Severe"
... View more