data have; length Name $18 ALine1 $18 ALine2 $25; input Name @24 ALine1 $18. @44 ALine2 $25.; datalines; VALERIE C SANDMIRE 1302 ELLENWOOD DR MADISON WI 53714-1006 JONAH Z HAUGLEY 884 HUNTERS TRL SUN PRAIRIE WI 53590-2585 DOROTHY A GENSKE 700 DOUGLAS TRL MADISON WI 53716-2125 ; run; This program depends on: [1] count the number of words in ALine2. [2] Gets the Zip at the last word adjusting for '-'. [3] State is last but one word. [4] Taking the beginning location of State, Addr2 is found in the first location - 1 positions. data want; format Name ALine1 Addr2 State Zip; keep Name ALine1 Addr2 State Zip; length State $2 zip $5 Addr2 $12; set have; num = countw(ALine2, ' '); Zip = scan(ALine2, num, ' -'); State = scan(ALine2, num - 1, ' '); loc = index(ALine2, State); Addr2 = substr(ALine2,1, loc - 1); run;
... View more