Help using Base SAS procedures

SAS Query - Where data not present in one dataset

Reply
Frequent Contributor
Posts: 145

SAS Query - Where data not present in one dataset

[ Edited ]

Dear All,

 

Can some one help me with below query. I have 1st dataset with three variables.

Id, date, term

 

 

I have second dataset with below three variables.

Term1,date1,id

For both the dataset ID is the primary key variable. I would like to write a query to output when TERM is not equal to TERM1. Term and Term1 will not be same sorting order for one to one match.

The output should look like this.

 

12004002 TRAMADOL UN/AUG/2014

12004002 MICONAZOL 18/JAN/2016

Thanks

Rakesh

Super User
Posts: 10,538

Re: sas query

Which variables are in the output? Term, Term1, Date or date1 (assuming that ID is one of the output variables).

 

 

Frequent Contributor
Posts: 145

Re: sas query

the variables present in the output should be id,term,term1,date

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Super User
Posts: 17,912

Re: sas query

What about dates? Do those have to match or be within a window of each other?

Super User
Posts: 10,538

Re: sas query

This may give what your are looking for if I understand the problem:

proc sql;
   create table want as
   select table1.id, table1.term,table1.date, table2.term1
   from table1 left join table2 
      on table1.id=table2.id
   where table1.term ne table2.term1;
quit;
Super User
Posts: 5,260

Re: sas query

I'm confused. If ID is the PK then there should be no sort order for term..?
Data never sleeps
Ask a Question
Discussion stats
  • 5 replies
  • 280 views
  • 0 likes
  • 4 in conversation