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.

Answer Posted / arun & g.n.rao

data one;
input ID$ NAME$;
datalines;
A01 SUE
A02 TOM
A05 KAY
A10 JIM
;
RUN;
DATA TWO;
INPUT ID$ AGE SEX$;
DATALINES;
A01 58 F
A02 20 M
A04 47 F
A10 11 M
;
RUN;

DATA N1 N2 N3;
MERGE ONE (IN=X) TWO (IN=Y);
BY ID;
IF X=1 AND Y=1 THEN OUTPUT N1;
IF X=1 AND Y=0 THEN OUTPUT N2;
IF X=0 AND Y=1 THEN OUTPUT N3;
RUN;

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

data data1; input dt account; format dt date9.; cards; 1745 1230 1756 1120 1788 1130 1767 1240 ; data data2; input startdt enddt total; format startdt date9. enddt date9.; cards; 1657 1834 12300 1557 1758 16800 1789 1789 12300 1788 1345 12383 1899 1899 13250 ; proc sql; create table data3 as select * from data1 as x left join data2 as y on x.dt>=y.startdt and x.dt<=y.enddt; quit; Here, we are getting cartision product. But,I want left join report consisting of this program. It should not get duplicate values. you can modify the program also.

1795


explain what is factor analysis? : Sas-administrator

600


is data integration and etl programming is same? : Sas-di

574


for report generation which one you used proc report or data_null_?

6578


If money were no object, what would you like to do?

2684






How do you test for missing values?

1053


explain the use of % includes a statement in sas? : Sas-administrator

543


how do you debug and test your sas programs? : Sas programming

558


explain the difference between proc means and proc summary?

668


describe how to adjust the performance of data integrator? : Sas-di

561


Explain input and put function?

643


describe about metadata object? : Sas-di

621


Name some categories in sas 9? : sas-grid-administration

555


How to read an input file in sas?

652


Mention the category in which sas informats are placed?

624