BookmarkSubscribeRSS Feed
Alexxxxxxx
Pyrite | Level 9

Hi,

 

I am running code like below,

 

PROC SQL;
	CREATE TABLE want.C  AS
	SELECT DISTINCT
	*
	FROM
	have.A as A
	JOIN have.B AS B ON A.family_id=B.family_id
	;
QUIT;

my question is: How to write the code if I would like to get the same result by using 'merge' function?

I try to use 

data want.C;
	merge have.A 
	have.B;
	by family_id;
run;

 

But I did not get the same result. could you please give me some suggestions about this?

Thanks in advance.

 

 

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Try this

 

data want.C;
	merge have.A (in=a)
	have.B (in=b);
	by family_id;
	if a and b;
run;
Alexxxxxxx
Pyrite | Level 9
Thanks for your reply. but what should I do? the result of SQL is 'Error: Sort execution failure.' Could you please give me some suggestions about this?
Kurt_Bremser
Super User

@Alexxxxxxx wrote:
Thanks for your reply. but what should I do? the result of SQL is 'Error: Sort execution failure.' Could you please give me some suggestions about this?

See your other thread about this.

Ksharp
Super User
Try FULL JOIN .
Better post sample data ,and can test the code .

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 416 views
  • 2 likes
  • 4 in conversation