BookmarkSubscribeRSS Feed
SASdevAnneMarie
Barite | Level 11

Hello Experts,

 

I have a file with duplicate values and the same data with no duplicate values. I can import the 2 files. Do you know please how to find the key of sorting ? 

 

Thank you !

4 REPLIES 4
andreas_lds
Jade | Level 19

I am sure that i don't understand your problem.

If you use proc sort with "presorted" options, sas will only sort the dataset if it is not already sorted by the variable you provide.

Patrick
Opal | Level 21

@SASdevAnneMarie  Put yourself into our shoes and assume you read below without any further information and context:

 

I have a file with duplicate values and the same data with no duplicate values. I can import the 2 files. Do you know please how to find the key of sorting ? 


...and now that you understand please try and provide all the necessary information so we can help you to help yourself.

SASdevAnneMarie
Barite | Level 11
Hello Patrick,
I mean that I would like to do the proc compare between sorted and not sorted data. But I don’t know if proc compare can indicate the duplicate values. Thank you for your help.
Rick_SAS
SAS Super FREQ

It sounds like you have one data set that is unsorted and you want to check whether the unique values in the data match a specified set of "target" values, which are in a second data set. To do that you can use PROC SORT with the NODUP option and compare the output to the set of "target" values:

/* orig data */
data Have;
input x @@;
datalines;
4 3 2 5 6 4 3 2 2 2 3 5 4 7
;
proc sort data=Have nodup out=Want;
  by x;
run;

/* unique values ("target" values) that we want to compare against */
data Unique;
input x @@;
datalines;
2 3 4 5 6 7
;

proc compare base=Unique compare=Want;
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!

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
  • 4 replies
  • 339 views
  • 2 likes
  • 4 in conversation