BookmarkSubscribeRSS Feed
Mona1
Calcite | Level 5

hi,

 

I am havig the following dataset

Customer Month      Type    Amount

A1        03JAN2004 PETRO 2000

A1        03JAN2004 PETRO 2000

A1        12JAN2004 JEWELLWERY 1000

A1        12JAN2004 JEWELLWERY 1000

 

Iam not getting the code for taking the duplicate values out in a separate dataset. Iam using this code

 

Proc sort data=valid_cards1 nodupkey nodopout=duplicates;
by customer month type amount;
run;

 

 Can anybody help?

 

Thanks & Regards

Mona

 


Capture.PNG
3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

NODUPKEY option: Deletes observations with duplicate BY values

 

DUPOUT= option: Specifies the output data set to which duplicate observations are written.

 

I think your code has some misspelling and should be as this:

 

data valid_cards1;
input Customer$ Month:date9. Type$ Amount;
format Month date9.;
datalines;
A1 03JAN2004 PETRO 2000
A1 03JAN2004 PETRO 2000
A1 12JAN2004 JEWELLWERY 1000
A1 12JAN2004 JEWELLWERY 1000
;

Proc sort data=valid_cards1 nodupkey dupout=duplicates;
by customer month type amount;
run;

See the available options in the documentation here

 

https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000146878.htm 

bindhureddiee
Calcite | Level 5
Try
Proc sort data=valid_cards out=valid_cards_clean dupout=duplicates nodupkey;
By customer month type amount;
Format month date9.;
Run;


You didn't used outfile option

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
  • 5970 views
  • 2 likes
  • 3 in conversation