removing duplicate (by year and group)

Reply
Occasional Contributor
Posts: 7

removing duplicate (by year and group)

Hi All, I have a data that looks something like this:

Group     Year           Frequency

A            2010               5

A            2010               5

A            2012               10

A            2012               10

B            2012               6

B            2012               6

B            2012               6

B            2011               25

B            2011               25

C            1999               1

C            1999               1

C            2000               3

C            2000               3

My question is, how do i remove duplicates so that it looks like this:

Group       Year           Frequency

A              2010               5

A              2012               10

B              2012               6

B              2011               25

C              1999               1

C              2000               3

Thank You.

Respected Advisor
Posts: 3,156

Re: removing duplicate (by year and group)

Posted in reply to zizou1845

Hi,

please refer to the answer that I have posted in another thread of yours.

Regards,

Haikuo

Occasional Contributor
Posts: 7

Re: removing duplicate (by year and group)

Hi Hai.kuo,

I was trying to use the Proc SQL, create table, select distinct method but I realised that if my data were to look something like this, would I still be able to get end results (bottom table) that i want? (Ignore the no. of attempts. I want distinct group year and frequency).

Group     Year           Frequency     no. of attempts

A            2010               5                      10

A            2010               5                      3

A            2012               10                    4

A            2012               10                    1

B            2012               6                      2

B            2012               6                      5

B            2012               6                      1

B            2011               25                    2

B            2011               25                    12

C            1999               1                      3

C            1999               1                      6

C            2000               3                      8

C            2000               3                      1

Group       Year           Frequency

A              2010               5

A              2012               10

B              2012               6

B              2011               25

C              1999               1

C              2000               3

Thank You.

Respected Advisor
Posts: 3,156

Re: removing duplicate (by year and group)

Posted in reply to zizou1845

In that case, you need to spell out the variables of interest explicitly.

proc sql;

  create table want as

   select distinct group, year, frequency from have;

quit;

Regards,

Haikuo

Ask a Question
Discussion stats
  • 3 replies
  • 245 views
  • 0 likes
  • 2 in conversation