An INFORMAT may be a good choice. As it offers some advantages over a FORMAT with the UPCASE and JUST options and it creats the numeric value directly.
[pre]
proc format;
INvalue news(just upcase) 'EAST'=1 'WEST'=2 'NORTH'=3 'SOUTH'=4;
run;
data news;
length news $8;
do news='East', 'WEST', ' NORTH', 'SOUTH';
code = input(news,news8.);
output;
end;
run;
proc print;
run;
Obs news code
1 East 1
2 WEST 2
3 NORTH 3
4 SOUTH 4
[/pre]
As in this case where the default W for the user defined INFORAMT is 5, be sure to specify a W that is wide enough to read the entire field. JUST takes place after the read but before the comparison with INVALUESlist.