Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sas9 Replace special characters with underscores

In Sas9, how can I replace all the , \ / or spaces, and other special characters of my choosing with underscores? A solution either in a datastep or in macro functions would do the trick, I'm just looking for a method to do it.

Thanks

like image 851
Dan Avatar asked Feb 03 '26 03:02

Dan


1 Answers

You can use the Perl regular expression functionality built into SAS.

data tmp;
 set tmp;
 var1 = prxchange('s/[,\/\\]/_/', -1, var);
run;

or something similar.

like image 178
itzy Avatar answered Feb 05 '26 07:02

itzy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!