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

What does the RUN statement do?

0 Answers   Quintiles,


What has been your most common programming mistake?

4 Answers   Wipro,


what are scrubing procedures in SAS?

1 Answers   Oracle,


how the sas basic syntax style described? : Sas-administrator

0 Answers  


Have you ever linked SAS code, If so, describe the link and any required statements used to either process the code or the step itself?

4 Answers  






what is operational data and operational system? : Sas-di

0 Answers  


if a program has some 1000 or more line and how to know whether the syntax of the particular code is correct without checking it manually

4 Answers   Accenture,


what is sas data set?

0 Answers  


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

0 Answers  


List down the reasons for choosing sas over other data analytics tools.

0 Answers  


what is the difference between proc report and proc format?

7 Answers   CTS,


How to import multiple xls files into sas. Out of those files, how to get different values from a single variable and how to find number of rows per value type? We can do this using group by for one xls file with proc sql. Was wondering how I can achieve this for multiple files at the same time. Any ideas?

0 Answers  


Categories