BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SSK_011523
Calcite | Level 5

Hello, 

 

I have identified regimens and want to categorize into different categories:

1) Chemo with cisplatin

2)Chemo without Cisplatin

3)Immunotherapy 

4)Targeted therapy 

 

Data want;

infile ID$ REGIMEN$

 

1   Cisplatin+Gemcitabine

2   Carboplatin+Cisplatin+Gemcitabine+Pembrolizumab

3   Pembrolizumab

4  Fluorouracil+Mitomycin

5  Enfortumab

 

ID 1 and ID 2 have cisplatin in them and should be categorized under "chemo with cisplain". ID 3 - immunotherapy; ID-4:chemo without cisplatin; ID 5 -targeted therapy. 

 

I tried using if..then statement for example  - 

if find(regimen_1,'cisplatin' ,'i') then cisplatin= "yes";

if find(regimen_1,'pembrolizumab' ,'i') then immuno = "yes"

In this case ID 2 is categorized as "Chemo with cisplatin" as well as "Immuno". I just want it under "Chemo with cisplatin"

OUTPUT DESIRED

SSK_011523_0-1719522216849.png

 

Any help would be appreciated

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Instead of just IFs, use ELSE IFs:

if find(regimen_1,'cisplatin' ,'i') then cisplatin= "yes";
else if find(regimen_1,'pembrolizumab' ,'i') then immuno = "yes"

The order of statements in the ELSE IF chain will define precedence.

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

Instead of just IFs, use ELSE IFs:

if find(regimen_1,'cisplatin' ,'i') then cisplatin= "yes";
else if find(regimen_1,'pembrolizumab' ,'i') then immuno = "yes"

The order of statements in the ELSE IF chain will define precedence.

A_Kh
Barite | Level 11

Hi, 

 

Did you list REGIMEN_1 all categories in your want example?  If, yes, use IF and ELSE IF statements instead of just 'IF' in your code. This should resolve the given example. 

 

 

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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