I have data that looks like -
row | episode | detail | date1 | date2 | detail2 |
1 | 1 | BIGUANIDES | 13-Feb-13 | 19-Jul-13 | BIGUANIDES |
2 | 4 | BIGUANIDES | 6-Sep-16 | 12-Oct-16 | BIGUANIDES |
3 | 3 | BIGUANIDES | 19-Oct-15 | 21-Jun-16 | BIGUANIDES |
4 | 2 | BIGUANIDES | 19-Nov-13 | 18-Dec-13 | BIGUANIDES |
5 | 1 | BIGUANIDES+DPP-4 | 19-Nov-13 | 18-Dec-13 | DPP-4 + BIGUANIDES |
6 | 5 | DPP-4+BIGUANIDES | 6-Sep-16 | 12-Oct-16 | DPP-4 + BIGUANIDES |
7 | 4 | BIGUANIDES | 19-Oct-15 | 21-Jun-16 | DPP-4 + BIGUANIDES |
8 | 3 | DPP-4 | 6-May-14 | 9-Oct-14 | DPP-4 + BIGUANIDES |
9 | 2 | DPP-4 | 5-Apr-14 | 4-May-14 | DPP-4 + BIGUANIDES |
I only want to keep rows where the column names: detail and detail2 are same
however do i identify cases like line5?
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;
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 16. Read more here about why you should contribute and what is in it for you!
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.