Below two coding options for replacing any non alphanumeric character (or underscore) with a blank.
If below sample code doesn't work for your real data then please be very specific what's not working and ideally provide amended sample data that demonstrates where the current result doesn't meet your desired result.
data _null_;
input have :$40.;
/* create target variables with same type and length than source variable */
if 0 then
do;
want1=have;
want2=have;
end;
/* option for single byte characters only */
want1=prxchange('s/\W/ /',-1,strip(have));
/* option that also allows for multi byte characters */
want2=ktranslate(strip(have), ' ', kstrip(kcompress(have, ,'n')));
/* print want variables */
file print;
put
'have: ' @10 have /
'want1: ' @10 want1 /
'want2: ' @10 want2 /
'-------------------------'
;
datalines4;
YT;-/*ADD^M
Y9;-/*A;;D@D^M
;;;;
run;
... View more