DATA Step, Macro, Functions and more

space and "/"

Accepted Solution Solved
Reply
Super Contributor
Posts: 704
Accepted Solution

space and "/"


I'm trying to replace space and "/"  with an underscore. but the following replaces only "/" with an undrscore not a space. Any help to include space in regex?

proc sql ;
   select catx('=',_name_,prxchange('s/[,\/\\]/_/', -1, col1))
     into :rename separated by ' '
         from temp;
         
quit;


Accepted Solutions
Solution
‎03-14-2018 07:32 PM
PROC Star
Posts: 2,317

Re: space and "/"

Or this is you want to use a character class.

COL2=prxchange('s/[\/ ]/_/', -1, '1/2 3');

 

View solution in original post


All Replies
PROC Star
Posts: 2,317

Re: space and "/"

Like this?

data t;
  COL2=prxchange('s/(\/| )/_/', -1, '1/2 3');
  put COL2=;
run;

COL2=1_2_3

 

Solution
‎03-14-2018 07:32 PM
PROC Star
Posts: 2,317

Re: space and "/"

Or this is you want to use a character class.

COL2=prxchange('s/[\/ ]/_/', -1, '1/2 3');

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 104 views
  • 0 likes
  • 2 in conversation