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;

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 267 views
  • 1 like
  • 2 in conversation