Hi
I am trying to find same value in multiple variables. Can gurus help simplest way. I can do it several OR statements, but what if I have more variables (when transposed) at later point.
Thanks
I was using code something like below:, but nothing worked.
if NUM=4 and (name='SKECCD' and col1-col9 in (14 32)) and (name='SKCHSTCD' and col1-col9 in (1 3));
or
if NUM=4 and (name='SKECCD' and col: in (14 32)) and (name='SKCHSTCD' and col: in (1 3));
or
if NUM=4 and (name='SKECCD' and col1:col9 in (14 32)) and (name='SKCHSTCD' and col1:col9 in (1 3));
Data I have: (COL1 TO COL9 variables may increase or decrease)
PTID | NUM | DATE | NAME | COL1 | COL2 | COL3 | COL4 | COL5 | COL6 | COL7 | COL8 | COL9 |
12 | 4 | 25-Apr-13 | SKECCD | 34 | 72 | 72 | ||||||
12 | 4 | 25-Apr-13 | SKCHSTCD | 1 | 5 | 3 | ||||||
21 | 4 | 8-Sep-11 | SKECCD | 34 | NC | 34 | ||||||
21 | 4 | 8-Sep-11 | SKCHSTCD | 5 | 1 | 3 | ||||||
21 | 4 | 9-Sep-11 | SKECCD | 14 | 14 | |||||||
21 | 4 | 9-Sep-11 | SKCHSTCD | 5 | 3 | |||||||
21 | 4 | 10-Aug-11 | SKECCD | 35 | 72 | |||||||
21 | 4 | 10-Aug-11 | SKCHSTCD | 1 | 1 | |||||||
31 | 4 | 24-Oct-12 | SKECCD | 32 | ||||||||
31 | 4 | 24-Oct-12 | SKCHSTCD | 1 | ||||||||
31 | 4 | 24-Sep-10 | SKECCD | 44 | ||||||||
31 | 4 | 24-Sep-10 | SKCHSTCD | 1 | ||||||||
35 | 4 | 10-Feb-11 | SKECCD | 14 | ||||||||
35 | 4 | 10-Feb-11 | SKCHSTCD | 1 | ||||||||
35 | 4 | 13-Jan-11 | SKECCD | 72 | ||||||||
35 | 4 | 13-Jan-11 | SKCHSTCD | 1 | ||||||||
35 | 4 | 22-Dec-10 | SKECCD | 72 | NC | |||||||
35 | 4 | 22-Dec-10 | SKCHSTCD | 1 | 1 | |||||||
36 | 4 | 19-Oct-11 | SKECCD | NC | 14 | 14 | NC | NC | 14 | NC | ||
36 | 4 | 19-Oct-11 | SKCHSTCD | 5 | 5 | 5 | 5 | 5 | 5 | 3 | 3 | |
37 | 4 | 5-Oct-11 | SKECCD | 14 | nc | 34 | 14 | nc | 14 | 14 | 34 | nc |
37 | 4 | 5-Oct-11 | SKCHSTCD | 5 | 5 | 5 | 5 | 5 | 5 | 3 | 3 | 3 |
NEED:
PTID | NUM | DETHFLAG | DATE |
12 | 4 | N | 25-Apr-13 |
21 | 4 | Y | 10-Aug-11 |
31 | 4 | Y | 24-Sep-10 |
35 | 4 | Y | 22-Dec-10 |
36 | 4 | Y | 19-Oct-11 |
37 | 4 | Y | 5-Oct-11 |
Look at the WhichN function, but you'll still have to write it out for each value you're looking for, just not for all the columns
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.