Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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 / tangyoulei

data new1 new2 new3;
merge old1 (in=one) old2 (in=two);
if one and two then output new1;
else if one and not two then output new2;
else output new3;
run;

Is This Answer Correct ?    16 Yes 0 No

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

Answer / 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

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

Answer / proc sql

proc sql:
proc sql;
create table sqln1 as select one.id,name,age,sex from one
inner join two on one.id=two.id;
create table sqln2 as select one.id,name,age,sex from one
left join two on one.id=two.id where two.id is null;
create table sqln3 as select two.id,name,age,sex from one
right join two on one.id=two.id where one.id is null;
quit;

Is This Answer Correct ?    5 Yes 0 No

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

Answer / vinod swarna

proc sql;

create table both_match as
select *
from one
intersect
select *
from two;

create table left_non as
select *
from one
except
select *
from two;

create table right_non as
select *
from two
except
select *
from one;

quit;

Is This Answer Correct ?    2 Yes 0 No

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

Answer / lakshmi

data data1 data2 data3;
merge left(in-a) right(in=b);
by subjid;
if a and b then output data1;
if a and not b then output data2;
if b and not a then output data3;
run;

Is This Answer Correct ?    2 Yes 0 No

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

Answer / vipin choudhary

Assume the common variable in both of the old datasets
is "name".
Data One two three;
merge old(in = in1) old1(in = in2);
by name;
if in1 and in2 then output one;
if in1 then output two;
if in1 = 0 and in2 = 1 then output three;
run

Is This Answer Correct ?    1 Yes 0 No

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

Answer / giri

this problem over come by using the joins statements

Is This Answer Correct ?    0 Yes 0 No

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

Answer / vinod

what is the error u r getting ?

Is This Answer Correct ?    1 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 / m.sivakumar

proc sql;

create table sqln1 as select one.id,name,age,sex from one
inner join two on one.id=two.id;

create table sqln2 as select one.id,name,age,sex from one
left join two on one.id=two.id where two.id is null;

create table sqln3 as select coalesce(one.id,two.id)as
id,name,age,sex from one right join two on one.id=two.id
where one.id is null;

quit;

Is This Answer Correct ?    0 Yes 0 No

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

Answer / padma

The above proc sql is not working. it is throwing up error.

Please verify. If anybody give proc sql code for the above
question that would be great.

padma

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More SAS Interview Questions

What is the difference between %put and symbolgen? : sas-macro

0 Answers  


How to read the file names of a text files from a shared drive using SAS?

1 Answers   HSBC, WNS,


How would you code the criteria to restrict the output to be produced?

9 Answers  


Which are the statements whose placement in the data step is critical?

0 Answers  


Explain data step in SAS

0 Answers  


What are the advantages of using sas?

0 Answers  


what is SAS/Access and SAS/Connect?what are the uses?

3 Answers  


CHOOSE ANY ONE OF THE PROCEDURE FOLLOWING TO GENERATE THE REPORTS? HOW CAN YOU SAY IT IS BETTER THAN THE OTHER? AND DEFERENCIATE THESE TWO ? 1). REPORT PROCEDURE 2). TABULATE PROCEDURE

4 Answers   CybAge,


Hi, I have one dataset, could you please ans for this. id amount paid_amount 1 700 400 2 900 250 3 300 300 a 400 250 b 500 320 c 800 650 x 200 190 y 900 250 z 300 180 i want create new dataset having id and paid_amount who are paid high amount comparing amount. ex: 1d paid_amount 3 300 c 650 x 190

3 Answers  


"What is the difference between proc sort nodup and proc sort nodupkey?"

2 Answers  


Write SAS codes to compare two datasets. Suppose the allowable difference is 0.1.

2 Answers  


How to select the observations randomly from a SAS dataset

7 Answers   NTT Data,


Categories