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.
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.
Ready to level-up your skills? Choose your own adventure.