BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Sandeep77
Lapis Lazuli | Level 10

I have two SAS datasets. First one is Sep_release and second one is Oct_release. Both the datasets have REFERENCE_NUMBER as common variables. I want to find if the REFERENCE_NUMBER released in sep_release is also coming in Oct_release. Basically trying to find the duplicate REFERENCE_NUMBER in both the datasets. But I am unsure of best way of doing it. I tried proc sort and data step but not getting the result as the code is not right and I am unsure of the right way to approach. Can you please suggest?

data duplicate_REFERENCE_NUMBER;
 set sep_release oct_release;
 if not (first.REFERENCE_NUMBER) then output;
run;

Also, I tried this step

Proc sort data=sep_release
nodupkey dupout=oct_release;
by REFERENCE_NUMBER;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10
Using an inner join in PROC SQL should work:
proc sql;
create table duplicate_reference_number as
select a.REFERENCE_NUMBER
from sep_release a INNER JOIN oct_release b
on a.REFERENCE_NUMBER = b.REFERENCE_NUMBER;
quit;

View solution in original post

2 REPLIES 2
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10
Using an inner join in PROC SQL should work:
proc sql;
create table duplicate_reference_number as
select a.REFERENCE_NUMBER
from sep_release a INNER JOIN oct_release b
on a.REFERENCE_NUMBER = b.REFERENCE_NUMBER;
quit;
Ksharp
Super User
data a;
set sashelp.class;
run;
data b;
set sashelp.class;
if _n_=1 then delete;
run;


proc sql;
create table duplicate_name as
select name from a
intersect
select name from b
;
quit;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

From SAS Users blog
Want more? Visit our blog for more articles like these.
5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 320 views
  • 1 like
  • 3 in conversation