Help using Base SAS procedures

Find same value(s) in multiple variables DataStep

Reply
Contributor
Posts: 32

Find same value(s) in multiple variables DataStep

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)

PTIDNUMDATENAMECOL1COL2COL3COL4COL5COL6COL7COL8COL9
12425-Apr-13SKECCD347272
12425-Apr-13SKCHSTCD153
2148-Sep-11SKECCD34NC34
2148-Sep-11SKCHSTCD513
2149-Sep-11SKECCD1414
2149-Sep-11SKCHSTCD53
21410-Aug-11SKECCD3572
21410-Aug-11SKCHSTCD11
31424-Oct-12SKECCD32
31424-Oct-12SKCHSTCD1
31424-Sep-10SKECCD44
31424-Sep-10SKCHSTCD1
35410-Feb-11SKECCD14
35410-Feb-11SKCHSTCD1
35413-Jan-11SKECCD72
35413-Jan-11SKCHSTCD1
35422-Dec-10SKECCD72NC
35422-Dec-10SKCHSTCD11
36419-Oct-11SKECCDNC1414NCNC14NC
36419-Oct-11SKCHSTCD55555533
3745-Oct-11SKECCD14nc3414nc141434nc
3745-Oct-11SKCHSTCD555555333

NEED:

PTIDNUMDETHFLAGDATE
124N25-Apr-13
214Y10-Aug-11
314Y24-Sep-10
354Y22-Dec-10
364Y19-Oct-11
374Y5-Oct-11
Super User
Posts: 17,824

Re: Find same value(s) in multiple variables DataStep

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

Ask a Question
Discussion stats
  • 1 reply
  • 128 views
  • 0 likes
  • 2 in conversation