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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1176 views
  • 8 likes
  • 4 in conversation