Help using Base SAS procedures

How to replace date within a string

Reply
N/A
Posts: 1

How to replace date within a string

I need to replace value in a string - "the enddate of employee1 is 15/10/2012" to "the enddate of employee1 is". I am using tranwrd function as x1 = (x,"15/10/2012"," ");

This doesn't seem to be working. Any advise?

Super User
Posts: 9,682

Re: How to replace date within a string

data _null_;

a="the enddate of employee1 is 15/10/2012";

b=prxchange('s/\d+\/\d+\/\d+//',-1,a);

put a= b=;

run;

Trusted Advisor
Posts: 1,131

Re: How to replace date within a string

I am not sure if you have actually tried the below code with tranwrd function. This is working, please check

data have;

length x $200.;

x="the enddate of employee1 is 15/10/2012";

x1 = tranwrd(x,"15/10/2012"," ");

run;

Thanks,

Jag

Thanks,
Jag
Ask a Question
Discussion stats
  • 2 replies
  • 268 views
  • 1 like
  • 3 in conversation