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.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 480 views
  • 0 likes
  • 5 in conversation