BookmarkSubscribeRSS Feed
hovliza
Obsidian | Level 7

When I want to merge 6 datasets to one dataset like this:

*Merge datasets*;
DATA m.combined;
MERGE 	m.dataset1
	m.dataset2
	m.dataset3
	m.dataset4 
	m.dataset5
	m.dataset6; 
BY personnumber;
RUN;

Why do I get in my output table 3 times the same measurements for my personnumber like this:

 Personnumber

 Gender

Heigth

Weight

 1

 167

 56

 1

 167

 56

 1

 167

 56

 1

 188

 78

 1

 188

 78

 1

 188

 78

 2

 190

 102

 2

 190

 102

 2

 190

 102

 

I want to merge it like this:

 Personnumber

 Gender

 Heigth

Weight

 167

 56

 188

 78

 190

 102

 

There are no errors, so can someone please help? Thanks!

4 REPLIES 4
hovliza
Obsidian | Level 7

What do you mean? I can't post my whole dataset here..

Astounding
PROC Star

One of your incoming data sets (OK, possibly more than one) already contains multiple observations for each PERSONNUMBER.  You have to fix that data set first (again, possibly more than one data set to fix) if you want to end up with one observation apiece.

 

If you think it's legitimate that one of your incoming data sets contains multiple observations per personnumber, then you need to decide what should happen with those ... how can your input contain many, but your output only one?  What is the process to go through to narrow down the observations?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 639 views
  • 2 likes
  • 3 in conversation