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

Hi everyone

     I have tried to remove duplicates from my data set using sql distinct, max, etc but unfortunately it did not work.

Have:

COD_ACOD_B
11002200
110023010
1100215400

Want:

COD_ACOD_B
11002200

     It doesn’t matter with cod B will be chose in table want, what I really need is to update from tree observations, to just one but keeping cod_b in the result.

     I have tried many SQL solutions, like group by, distinct etc...

Thanks in advance

Regards

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

By datastep:

data have;

  attrib cod_a cod_b format=$10.;

  cod_a="11002"; codb="200"; output;

  cod_a="11002"; codb="3010"; output;

  cod_a="11002"; codb="15400"; output;

run;

proc sort data=have out=want;

  by cod_a cod_b;

run;

data want;

  set want;

  by cod_a;

  if first.cod_a then output;

run;

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

Have you tried:

proc sql;

  create table want as

    select distinct cod_a,min(cod_b) as cod_b

      from have

  ;

quit;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

By datastep:

data have;

  attrib cod_a cod_b format=$10.;

  cod_a="11002"; codb="200"; output;

  cod_a="11002"; codb="3010"; output;

  cod_a="11002"; codb="15400"; output;

run;

proc sort data=have out=want;

  by cod_a cod_b;

run;

data want;

  set want;

  by cod_a;

  if first.cod_a then output;

run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2028 views
  • 3 likes
  • 3 in conversation