BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
aanan1417
Quartz | Level 8

data have;

input id name;

datalines;

1 rahul

2 rohit 

3 nisha

9 kuldeep

;

run;

data have2;

input id name;

datalines;

1 rahul

2 rohit 

3 nisha

4 pukit

5 aakash

;

run;

 

 

final output should look like 

id name    remark

1 rahul       ok

2 rohit         ok

3 nisha       ok

9 kuldeep    notok

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Have you got instructions how to create the output? what are the rules ?

I suppose that if data on both datasets is the same then remark="OK";

else remark="NOTOK";

 

To achieve that use merge statement:

data want(drop=_name);
  merge have(in=in1) 
        have2(in=in2 rename=(name=_name));
  by ID;
      if in1 and in2 and name=_name then remark='ok';
      else if in1 and in2 then remark = 'notok';
      else delete;
run;

 

View solution in original post

1 REPLY 1
Shmuel
Garnet | Level 18

Have you got instructions how to create the output? what are the rules ?

I suppose that if data on both datasets is the same then remark="OK";

else remark="NOTOK";

 

To achieve that use merge statement:

data want(drop=_name);
  merge have(in=in1) 
        have2(in=in2 rename=(name=_name));
  by ID;
      if in1 and in2 and name=_name then remark='ok';
      else if in1 and in2 then remark = 'notok';
      else delete;
run;