BookmarkSubscribeRSS Feed
pdhokriya
Pyrite | Level 9

Hello,

 

I have 5 datasets (a,b,c,d,e) and all these 5 datasets has xyz variable with same datatype, please suggest in 1 query how can I pull observations (in 1 dataset) from xyz from all 5 datasets.

 

From: Priyanka

4 REPLIES 4
PaigeMiller
Diamond | Level 26

@pdhokriya wrote:

 

I have 5 datasets (a,b,c,d,e) and all these 5 datasets has xyz variable with same datatype, please suggest in 1 query how can I pull observations (in 1 dataset) from xyz from all 5 datasets.


Given the wording above, it is not clear if you are trying to find when observations have the same value of XYZ in all five data sets, or are you trying to find cases where a value in XYZ appears in more than one (but not all five) data sets, or even the situation where a value in XYZ appears in just one data set. Clarification would help.

 

Also, do you want to combine these data sets horizontally (MERGE or JOIN) or vertically (SET or UNION)?

--
Paige Miller
Quentin
Super User

Without much more information, sounds like a LEFT JOIN.

 

If you can post a small example of work.A, work.B, and work.C  (so DATA steps using CARDS statement to create each, maybe 5 rows of data, 3 variables) and then post the output you would want, along with the code you have tried, it will help people help you.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
ballardw
Super User

Strongly suggest that you provide some small examples and what the result is supposed to look like.

For example are any other variables to be included in the result? If they are have you verified the other variables that have the same name are of the same data type and length?

Is there supposed to be any indication of which data set a specific value came from?

How many values are involved? Do they need to change? (Goes to how to provide the list for selection, 2 or three are easy to place directly in code, 200 not so much).

Reeza
Super User
data want;
set a b c d e;
keep xyz;
run;

I suspect this isn't quite what you want so you'll need to provide more information - fake examples of your situation are fine.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 4 replies
  • 724 views
  • 0 likes
  • 5 in conversation