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

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.

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

View solution in original post

3 REPLIES 3
Reeza
Super User

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;
aminkarimid
Lapis Lazuli | Level 10

Capture.PNG

 

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

Reeza
Super User

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 426 views
  • 0 likes
  • 2 in conversation