Hi All,
I am not able to get the desired output by combining 2 data sets horizontally. I need the following type of output. I need maximum of rows for any value of variable pt and some values in combine data set should be blank. I am using the following code but it is not giving my any blank values in combine data set.
data combine;
merge a b;
run;
| Dataset A | Dataset B | Dataset Combine | ||||||
| pt | var1 | pt | var2 | pt | var1 | var2 | ||
| 1 | a | 1 | rrrr | 1 | a | rrrr | ||
| 1 | b | 1 | grg | 1 | b | grg | ||
| 2 | fg | 1 | saed2 | 1 | saed2 | |||
| 2 | d | 2 | fdf | 2 | fg | fdf | ||
| 2 | wd | 2 | 45fd | 2 | d | 45fd | ||
| 3 | s | 3 | 35r | 2 | wd | |||
| 3 | a | 3 | s | 35r | ||||
| 3 | ds | 3 | a | |||||
| 3 | ds | |||||||
Thanks
A few more lines of code would do it:
data combine;
merge a b;
by pt;
output;
var1=' ';
var2=' ';
run;
Good luck.
A few more lines of code would do it:
data combine;
merge a b;
by pt;
output;
var1=' ';
var2=' ';
run;
Good luck.
Thank you! It works.
Can you explain how it works, if u have time?
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!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.