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

Hello:

 

I would like to remove the group containing (10, 20, 30, and 40) duplicates with the stings the same in Class, Component and Product.   If the strings in Class, Component and Product are different, I would like to keep it.  Therefore, my final result should be something list below.   Please advice.   Thanks.

 

 

data test;

infile datalines dsd;

input Group Class : $20. Component : $20. Product : $20.;

datalines;

 

10, ANTI/INSULIN, , ,

10, ANTI/INSULIN, , ,

10, ANTI/VITA, , ,

15, PHENAZO, , ,

15, PHENAZO, , ,

19, Large, , ,

20, , HERBS, ,

20, , PSYCH, ,

20, , PSYCH, ,

22, , SKIN, ,

27, , HERBS, ,

27, , HERBS, ,

30, ANTI/INSULIN, , PHENAZO,

30, ANTI/INSULIN, , PHENAZO,

40, , , FLOWER,

40, , , SUBST,

45, , , BANZOCAINE,

45, , , BANZOCAINE,

;

 

 

data final;

infile datalines dsd;

input Group Class : $20. Component : $20. Product : $20.;

datalines;

 

10, ANTI/INSULIN, , ,

10, ANTI/VITA, , ,

15, PHENAZO, , ,

15, PHENAZO, , ,

19, Large, , ,

20, , HERBS, ,

20, , PSYCH, ,

22, , SKIN, ,

27, , HERBS, ,

27, , HERBS, ,

30, ANTI/INSULIN, , PHENAZO,

40, , , FLOWER,

40, , , SUBST,

45, , , BANZOCAINE,

45, , , BANZOCAINE,

;

 

1 ACCEPTED SOLUTION

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

Then subset + sort:

data temp;
  set have;
  where group in (10,20,30,40);
run;
proc sort data=temp nodupkey;
  by group class;
run;
data want;
  set have (where=(group not in (10,20,30,40)) temp;
run;

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Is that really your question, as I would think:

proc sort data=test nodupkey;
  by group class;
run;

Would suffice?

ybz12003
Rhodochrosite | Level 12

Hi RW9:

 

I apologized that I didn't make my sample dataset clearly.   I only need to remove the duplicated in (10, 20, 30, 40).  In other word, if the duplicates are in (15, 27, and 45), I would like to keep them.   Please see my adjusted post above.   Thanks. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Then subset + sort:

data temp;
  set have;
  where group in (10,20,30,40);
run;
proc sort data=temp nodupkey;
  by group class;
run;
data want;
  set have (where=(group not in (10,20,30,40)) temp;
run;
ybz12003
Rhodochrosite | Level 12

Awesome! thanks.

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