BookmarkSubscribeRSS Feed
ybz12003
Rhodochrosite | Level 12

Good morning,

 

Dataset A which contains 10,000 observations and 700 variables;

Dataset B, which contains 2,000 observations and 10 variables.

 

Both A and B have the same three columns, including ID column.   All the 2,000 IDs of dataset B are from dataset A.    The IDs in both A and B datasets are non-duplicated.   Dataset B has some updated information if the same columns are in both datasets. 

 

I would like to merge two datasets.   The final dataset C should contain 10,000 observations and 707 variables with updated information of dataset B, including the 7 new columns from B too.  Please help me to approach this procedure, thank you.

2 REPLIES 2
Sajid01
Meteorite | Level 14

Your situation is pretty straight forward.
Your question would have solution  in the books (The little SAS Book, Learning SAS by Example) and various articles.

This is a must have https://documentation.sas.com/api/docsets/basess/9.4/content/basess.pdf  (Chapter 16)
One example is https://www.lexjansen.com/nesug/nesug11/ds/ds03.pdf 
Please revert back when you have issues.

One important suggestion : start with a small dataset of 20 -30 observations.
Sample datasets in the books will help.
Once you are through apply to the complete datasets.

Tom
Super User Tom
Super User

What does this statement mean?

Dataset B has some updated information if the same columns are in both datasets. 

 Does that mean that some of the NON KEY variables in the two datasets are the same?

 

If so and both A and B have unique observations per by group then a simple MERGE will replace the values read from A with the values read from B.

 

But if A has repeating observations for the same by group then a simple merge will not work.

 

Please provide a detailed example of your situation using as few observations and variables as possible.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 697 views
  • 0 likes
  • 3 in conversation