BookmarkSubscribeRSS Feed
riya275
Obsidian | Level 7

I have data that looks like -

rowepisodedetaildate1date2detail2
11BIGUANIDES13-Feb-1319-Jul-13BIGUANIDES
24BIGUANIDES6-Sep-1612-Oct-16BIGUANIDES
33BIGUANIDES19-Oct-1521-Jun-16BIGUANIDES
42BIGUANIDES19-Nov-1318-Dec-13BIGUANIDES
51BIGUANIDES+DPP-419-Nov-1318-Dec-13DPP-4 + BIGUANIDES
65DPP-4+BIGUANIDES6-Sep-1612-Oct-16DPP-4 + BIGUANIDES
74BIGUANIDES19-Oct-1521-Jun-16DPP-4 + BIGUANIDES
83DPP-46-May-149-Oct-14DPP-4 + BIGUANIDES
92DPP-45-Apr-144-May-14DPP-4 + BIGUANIDES

 

 

I only want to keep rows where the column names:  detail and detail2 are same

however do i identify cases like line5?

 

 

2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi,
In addition to LINE 5, I think you also have an issue in LINE 6. You have spaces between the 2 words and the plus in DETAIL2, but do not have extra spaces in DETAIL. Would you want those to be treated the same?
Cynthia
nicobuettner
SAS Employee

Like this?

data temp;
  attrib detail1 length=$30;
  attrib detail2 length=$30;
  attrib d11 length=$30;
  attrib d12 length=$30;
  attrib d21 length=$30;
  attrib d22 length=$30;
  attrib flag length=3;

  detail1 = "BIGUANIDES+DPP-4";
  detail2 = "DPP-4 + BIGUANIDES";

  d11 = scan(compress(detail1, ' '), 1, '+');
  d12 = scan(compress(detail1, ' '), 2, '+');

  d21 = scan(compress(detail2, ' '), 1, '+');
  d22 = scan(compress(detail2, ' '), 2, '+');

  if (d11 eq d21 or d11 eq d22)
    and (d12 eq d21 or d12 eq d22)
    then flag = 1;
  else flag = 0;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 446 views
  • 0 likes
  • 3 in conversation