The following code is inspired by @RW9's block approach, only to avoid the hard coding. The block size is 10 digits. data have;
charID = "1037699710538224500199468064894";
output;
charid = '1999999999999999999999999999999';
output;
charid = '9999999999999999999999999999997';
output;
run;
data want;
set have;
length new_id $ 40;
r_id=reverse(charid);
do i=0 to int(length(r_id)/10);
c=reverse(substr(r_id,i*10+1,10));
if i=0 then
n=c+263;
else n=c+flag;
flag=length(cats(n))>10;
if i = int(length(r_id)/10) then
new_id=cats(reverse(substr(reverse(n),1,10)), new_id);
else new_id=cats(reverse(substr(reverse(put(n,z15.)),1,10)), new_id);
/* output;*/
end;
keep charid new_id;
run;
... View more