DATA Step, Macro, Functions and more

How do I change the value if the value contains a specific content?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

How do I change the value if the value contains a specific content?

Hello,

I use SAS 9.4 and I have a variable like this:

study_id

CS-02-0001

CS-02-0002

CS-02-0003

...

 

I hope to change it to CS-01-0001,CS-01-0002,... In other words, I want to change the part to CS-01 if the value includes CS-02. I think the codes should be something like: 

data want;
modify have;
if find(study_id,"CS-02") then ??;
run;

 

Does anyone can help me figure out the problem? Thank you!


Accepted Solutions
Solution
‎02-15-2017 05:26 PM
Contributor
Posts: 21

Re: How do I change the value if the value contains a specific content?

I hope this helps u
study_id=Tranwrd(study_id,'CS-02','CS-01');

View solution in original post


All Replies
Solution
‎02-15-2017 05:26 PM
Contributor
Posts: 21

Re: How do I change the value if the value contains a specific content?

I hope this helps u
study_id=Tranwrd(study_id,'CS-02','CS-01');
Occasional Contributor
Posts: 17

Re: How do I change the value if the value contains a specific content?

Thank you so much! It works!

Contributor
Posts: 21

Re: How do I change the value if the value contains a specific content?

you're welcome
☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 106 views
  • 0 likes
  • 2 in conversation