How would you code a merge that will write the matches of
both to one data set, the non-matches from the left-most
data set to a second data set, and the non-matches of the
right-most data set to a third data set?
Answers were Sorted based on User's Feedback
Answer / sas job searcher
data x1y1
x1y0
x0y1;
/* x1y1, x1y0, x0y1 are output data set names */
merge left_most(in=x) right_most(in=y);
by id;
/* write all matches to x1y1: */
if x=1 and y=1 then output x1y1;
/* non-matches from the left-most data set: */
if x=1 and y=0 then output x1y0;
/* non-matches from the right-most data set: */
if x=0 and y=1 then output x0y1;
run;
| Is This Answer Correct ? | 11 Yes | 1 No |
Answer / reddy
data both left_only right_only;
merge dataset1(in=a) dataset2(in=b);
by variable;
if a and b then output both;
if a and not b then output left_only;
if b and not a then output right_only;
run;
i think these is the easy way of writing the code,if any
one nows other please specify.thanks!
| Is This Answer Correct ? | 11 Yes | 4 No |
Have you been involved in editing the data or writing data queries?
1 Answers BioServe, Oracle, Sasken,
Code a PROC SORT on a data set containing State, District and County as the primary variables, along with several numeric variables?
what are some differences between proc summary and proc means? : Sas programming
What is the basic syntax style in SAS?
% let A=3+4 what is result
what is the difference between proc means and proc tabulate?
What is the differnce between SDTM 3.1.2 to 3.1.1 version
What is substr function?
what is broad cast agent? : Sas-bi
what is syntax of proc merge ?
How to convert a numeric variable to a character variable?
What is the order of evaluation of the comparison && logical && relational operators:?