I would go for a regular expression, see below: The \d idenifies digits, the + matches one or more times, the $ matches the position at the end of the input string It is important to trim the string first data have; infile cards truncover; input error $200.; cards; 1 LLLL MMMMM NNNN Missing0048165a 2 LLLL MMMMM NNNN Missing 3 AAAAAA BBBBB CCCCCCCC segment Required0048158 4 AAAAAA BBBBB CCCCCCCC segment Required 5 XXXX YYYYYY ZZZZZZ (Required) Missing0000047 6 XXXX YYYYYY ZZZZZZ (Required) Missing ; data want; set have; digitStart = prxmatch("/\d+$/", trim(error)); part1 = substr(error, 1, digitStart-1); part2 = substr(error, digitStart); run;
... View more