DATA Step, Macro, Functions and more

duplicate lines

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

duplicate lines

Hello All!

I have some lines of output that are exactly the same. 

Like example 

mem id- 2. spent-$5. store-walmart. toy-barbie.

mem id- 2. spent-$5. store-walmart. toy-barbie.

Does anyone have example code to get rid of this extra line that is exactly the same?

Mary


Accepted Solutions
Solution
‎01-25-2016 11:33 AM
Super Contributor
Posts: 490

Re: duplicate lines

Posted in reply to wilsonm3e

For example

Data have;
input ID Date Amount;
cards;
111 1 30
111 1 34
111 1 34
111 5 70
111 5 70
111 5 70
112 2 79
112 5 5
;
run;

proc sql ;
create table have_nodup as
select distinct *
from have
;
quit;

This is very easy one

View solution in original post


All Replies
Occasional Contributor
Posts: 5

Re: duplicate lines

Posted in reply to wilsonm3e
I am still new to sas so this seems easy, but I cant seem to get rid of all them.
Solution
‎01-25-2016 11:33 AM
Super Contributor
Posts: 490

Re: duplicate lines

Posted in reply to wilsonm3e

For example

Data have;
input ID Date Amount;
cards;
111 1 30
111 1 34
111 1 34
111 5 70
111 5 70
111 5 70
112 2 79
112 5 5
;
run;

proc sql ;
create table have_nodup as
select distinct *
from have
;
quit;

This is very easy one

Occasional Contributor
Posts: 5

Re: duplicate lines

Posted in reply to mohamed_zaki

Thank you!

Super User
Posts: 19,817

Re: duplicate lines

Posted in reply to wilsonm3e

If something isn't working, its helpful to post what you've tried so we know where you're trying to go with it. Also, you'll find out where the code is incorrect and needs modifications.

Super User
Posts: 19,817

Re: duplicate lines

Posted in reply to wilsonm3e
  1. select distinct with PROC SQL
  2. Proc sort nodup - several options
  3. proc sort - data step with by groups

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 251 views
  • 3 likes
  • 3 in conversation