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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 1 reply
  • 629 views
  • 0 likes
  • 2 in conversation