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 (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at 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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 676 views
  • 0 likes
  • 5 in conversation