Dear,
I have a question.
I am merging two datasets. why only first OBS is populated in my output data. Please help. Thank you
code:
data data3;
merge data2(in=a) data1(in=b);
by id;
if a;
run;
data1
id value
1 10
2 20
3 30
data2
id
1
1
2
2
2
output getting;
id val
1 10
1
2 20
2
2
output needed;
id val
1 10
1 10
2 20
2 20
2 20
I'm using SAS 9.4 with SAS UE on linux.
Attached is the code and result.
The code is a copy of your (@knveraraju91 ) post, addaptedf to create test data.
The result is as you wanted.
Check your log and code again. It should work.
If not - what SAS version and platform you use ?
Are you sure that data2 only contains the variable id?
Please post the output of proc contents for both datasets.
The results you are getting would typically occur if your second data set also contained VAL (or is it VALUE?), but with all missing values. To get rid of it, you can drop it as late as on the MERGE statement:
data want;
merge data2 (in=a drop=val) data1;
by id;
if a;
run;
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.