Hi Experts,
I remember there is a SAS function which could remove all the "-" or "_" between the text, and compress the text? But I forgot which one. My variable is Charastatic. Please advice. Thanks.
data _null_;
want=compress("remove - or _","_-");
put want=;
run;
25 GOPTIONS ACCESSIBLE; 26 data _null_; 27 want=compress("remove - or _","_-"); 28 29 put want=; 30 run; want=remove or
data _null_;
want=compress("remove - or _","_-");
put want=;
run;
25 GOPTIONS ACCESSIBLE; 26 data _null_; 27 want=compress("remove - or _","_-"); 28 29 put want=; 30 run; want=remove or
I got it work, thanks.
Hi @ybz12003
Another possibility is to use the PRXCHANGE function:
data _null_;
want=prxchange('s/(^\s*|-|_|\s*$)//',-1," remove - or _ ");
run;
It looks for the following patterns ^\s*|-|_|\s*$
as many times as needed (-1):
and replace them by nothing.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.