I'm using zip codes, some of which start with a zero. I used the CATX, CATT, CATS, and CAT functions to try to concatenate a 0 then the remaining four digits to fix my current variable where the leading zero is missing. None of these worked. I'm left with a new variable with no leading zero for these. It's a character variable. (I need to fix this problem first because another issue I'll fix after this is dealing with xxxxx-xxxx zip codes. I don't think using LENGTH will fix my 4-digit issue since I'll need to chop off the correct side of my 9-digit ones later.) data new; set old; if length_zip=4 and state_code='CT' then zipcode=catt('0',zip); if length_zip=4 and state_code='ME' then zipcode=catt('0',zip); if length_zip=4 and state_code='MA' then zipcode=catt('0',zip); if length_zip=4 and state_code='MA' then zipcode=catt('0',zip); if length_zip=4 and state_code='NH' then zipcode=catt('0',zip); if length_zip=4 and state_code='NJ' then zipcode=catt('0',zip); if length_zip=4 and state_code='RI' then zipcode=catt('0',zip); if length_zip=4 and state_code='VT' then zipcode=catt('0',zip); else zipcode=zip; run;
... View more