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
Lapis Lazuli | Level 10

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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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