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.
Try this
data want.C;
merge have.A (in=a)
have.B (in=b);
by family_id;
if a and b;
run;
The data step MERGE cannot mimic the SQL join if there is a many-to-many relationship.
@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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.