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!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.