So I resolved soon after I posted.
I have to increase length of the variable.
Added this piece---length encrypt_names $512.;
Any better ways to encrypt values are more than welcome. Thank You
The new code is:
%let multi =3 ;
%let k = 359;
%let gap = 9;
data encrypt ;
set sashelp.class;
length encrypt_names $512.;
Encrypt_names = name;
i = input(&k., best.);
do old=
'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t',
'u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J',
'K','L','M','N','O','P','Q','R','S','T',
'U','V','W','X','Y','Z'
;
new=put(i,&multi..);
encrypt_names= tranwrd(encrypt_names,old,new);
i+input(&gap.,best.);
end;
drop i new old;
run;