Hi,
If I have two datasets, One and Two, both has a column named ID, how do I replace One's ID with Two's ID for just first 10 observations, ignoring all other vars?
Thanks!
Sounds like crazy thing to do.
data want;
merge one two(keep=id obs=10);
run;
Sounds like crazy thing to do.
data want;
merge one two(keep=id obs=10);
run;
Oops...it seems that method didn't work. Instead of replacing the first 10 IDs it added 10 rows with the CMIDs fro the second dataset Two to the first dataset, One.
It worked. I am an idiot. For some reason I used SET instead of MERGE. Sorry for spamming.
Thanks for the help!
If you want to use SET then add an IF statement.
data want;
set one;
if _n_ <= 10 then set two(keep=id);
run;
Wow! Thanks! It would be nice if I can do that with SAS. A MERGE with and without BY confuses me enough, lol. I need to get more practice for sure. Thanks again for teaching me the trick with the use of SET!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.