## How to find exact same observations?

Solved
Regular Contributor
Posts: 166

# How to find exact same observations?

Hello everybody,

I want to find observations which have same attitudes by TRD_EVENT_DT, TRD_STCK_CD, TRD_EVENT_TM, TRD_PR, TRD_TUROVR variables.

Variables are:

TRD_EVENT_DT = Date

TRD_STCK_CD = Name

TRD_EVENT_TM = Time

TRD_PR = Price

TRD_TUROVR = Turnover

I use code below:

``````proc sort data=sampledata out=sampledata01;
by  TRD_EVENT_DT TRD_STCK_CD TRD_EVENT_TM TRD_PR TRD_TUROVR;
run;
* Using PROC FREQ to find duplicate observations and route them to an output data set with multiple key variables;
proc freq data = sampledata01 noprint ;
by TRD_EVENT_DT TRD_STCK_CD TRD_EVENT_TM TRD_PR TRD_TUROVR;
table  TRD_EVENT_DT TRD_STCK_CD TRD_EVENT_TM TRD_PR TRD_TUROVR / out = sampledata_DUP
(keep = TRD_EVENT_DT TRD_STCK_CD TRD_EVENT_TM TRD_PR TRD_TUROVR Count where = (Count > 1)) ;
run;``````

Is this code true?

If not, Please tell me which statement is wrong.

Accepted Solutions
Solution
‎07-04-2017 07:26 PM
Super User
Posts: 23,296

## Re: How to find exact same observations?

Filter it. A duplicate will have a count of more than 1.

All Replies
Super User
Posts: 23,296

## Re: How to find exact same observations?

You should use PROC SORT to actively identify your duplicates.

If youre using PROC FREQ you need to remove the BY and add * between the variables.

This finds duplicates across age and sex.

``````Proc freq data = SASHELP.class;
Table sex*age / out = record_count list;
Run;``````
Regular Contributor
Posts: 166

## Re: How to find exact same observations?

This pic is a part of output.
@Reeza's codes shows frequency of all data. However, I just want to find duplicate observations.
Thanks.

Solution
‎07-04-2017 07:26 PM
Super User
Posts: 23,296