Is there a generic rule that can be applied to know that PBVSTOT1 should become PBVS111?
This works for the shown data but you may need to provide some RULES if any other values are involved.
Note the use of a data step to provide example data. That is what you should do to set the properties of YOUR variables to be correct for your problem.
Data have ;
input id $ ;/* note this defaults to 8 character length*/
datalines;
PBVS1
PBVS2
PBVS3
PBVS4
PBVS5
PBVS6
PBVS7
PBVS7A
PBVSTOT1
;
data want;
set have;
if index(id,'TOT')>0 then Id='PBVS111';
else id = tranwrd(id,'PBVS','PBVS10');
run;
The Tranwrd function will replace in the value of the first parameter the first group of characters , i.e. a word, with another .