Thursday, August 23, 2012

using prxchange in SAS to replace non-alpha and non-numeric characters to blanks


For example, we want to replace the special characters like "# $ ! & * ) ^" in the following words into blanks.


san francisco, @California
Oregon, && U^S
Google, *Mountain View


Function prxchange can be used:


data a;
input old & $100.;
cards;
san francisco, @California
Oregon, && U^S
Google, *Mountain View
;
run;


data a2;
set a;
new=
prxchange('s/[^a-zA-Z0-9]/ /i', -1, old);
run;

proc print data=a2;
run;


No comments:

Post a Comment