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



How would you code a merge that will write the matches of both to one data set, the non-matches fro..

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

How would you code a merge that will write the matches of both to one data set, the non-matches fro..

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

Post New Answer

More SAS Interview Questions

If you could design your ideal job, what would it look like?

0 Answers   Oracle,


data abc; input x y ; cards; 1 2 5 6 7 8 7 8 1 7 5 7 ; run; Proc Freq data=abc; tables x*y / chisq nopercent nocol norow PLCORR; RUN; If we run the code, we have Polychoric Correlation = 0.9054 in the last table. I want to extract this particular entry with the value. Means I will create one dataset in which this value will be stored/extracted. I need your help in coding this. Please help me out.

2 Answers  


Briefly describe 5 ways to do a "table lookup" in sas.

4 Answers   Quintiles,


What is difference between rename and lable in sas?

10 Answers   Satyam,


What is the difference between INPUT and INFILE ?

0 Answers  






What is program data vector (pdv) and what are its functions?

0 Answers  


How do you connect the desktop application to metadata server? : sas-grid-administration

0 Answers  


I use NOCUM/NOPERCENT option in the tables statement like this Proc freq data = deepak; tables x y /nocum nopercent; run; Here I get nopercent and nocum in the output only for variables x and y. How do i do it for all variables? Deepak

1 Answers  


Are you involved in writing the inferential analysis plan? Tables specifications?

0 Answers   Oracle,


what is sas database server? : Sas-di

0 Answers  


This entry was posted in General. Bookmark the permalink. Post a comment or leave

0 Answers   Quintiles,


1.What is the difference between _NULL_ , _ALL_, and _N_? 2.What are the uses of _NULL_ using in Data Steps? Can we _NULL_ in Proc Steps also? 3.How do call the macro variable in Data Steps? 4.How to construct Pivot tables in Excel Using SAS?

3 Answers  


Categories