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

Hi!

I have somewhat of a problem that I could not find a solution for.

I want to filter out datalines where variable A is not unique for any different variable B and C combination so that only one dataline remain.

 

    A B C

2 3 5

2 3 5

2 4 5

2 5 4

3 1 2

3 2 1

3 1 2

to

    A B C

1  2 3 5

2  2 4 5

3  2 5 4

4  3 1 2

5  3 2 1

 

I would much apreciate any help!

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

Hi @Viktoreli ,

 

You can try this::

 

data have;
	input A B C;
	cards;
2 3 5
2 3 5
2 4 5
2 5 4
3 1 2
3 2 1
3 1 2
;
run;

proc sort data=have;
	by A B C;
run;

data want;
	set have;
	by A B C;
	if first.C then output;
run;

View solution in original post

4 REPLIES 4
sustagens
Pyrite | Level 9
data have;
  input A:8. B:8. C:8.;
datalines;
2 3 5
2 3 5
2 4 5
2 5 4
3 1 2
3 2 1
3 1 2
;
run;

proc sort data=have nodupkey out=want;
by a b c;
run;
ed_sas_member
Meteorite | Level 14

Hi @Viktoreli ,

 

You can try this::

 

data have;
	input A B C;
	cards;
2 3 5
2 3 5
2 4 5
2 5 4
3 1 2
3 2 1
3 1 2
;
run;

proc sort data=have;
	by A B C;
run;

data want;
	set have;
	by A B C;
	if first.C then output;
run;