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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1169 views
  • 0 likes
  • 2 in conversation