Dear All,

I am trying to create a new "state" variable from certain city codes, one can observe that each city code has its own state number at the beginning. For example, 5 is state A and 99 is state Z. I was wondering if it is possible to extract the first (or first two) numbers from a city code and from that, create a new variable which assigns it to a state. I realize this is possible but due to my unfamiliarity with loops I would like to ask for anybody's help.

Thank you very much.

Juan