BookmarkSubscribeRSS Feed
Almighty
Fluorite | Level 6

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
1 REPLY 1
Reeza
Super User

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

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1408 views
  • 0 likes
  • 2 in conversation