BookmarkSubscribeRSS Feed
tulip
Calcite | Level 5
Hi, pros:

I have

data1: with a variable (Destination) with several values (123, 281, ...) ;
data2: structure as follows
id Des1 Des2 Des3
1 123 234 233
1 234 281 341
2 ....

Goal: if a person goes to any one of Destination by looking at 3 field of Des1, Des2, Des3, I would like to subset.

I can do it by using array and macro.

Do you think SQL can do a better job? If so, how. Please advise. Thanks.

Tulip.
2 REPLIES 2
LinusH
Tourmaline | Level 20
I don't know about better, I came to think of using IN sub-queries:

select data2.*
from data2
where data2.Des1 in(select Destination from data1)
or data2.Des2 in(select Destination from data1)
or data2.Des3 in(select Destination from data1)
;

If your destination table is not huge, it would be feasable.

/Linus
Data never sleeps
tulip
Calcite | Level 5
Hi, Linus:

Thanks a lot. It is much better than the way I used before.

Nice weekend, Tulip

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!

How to Concatenate Values

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.

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
  • 2 replies
  • 650 views
  • 0 likes
  • 2 in conversation