## WHERE clause with exclusion

Solved
Regular Contributor
Posts: 244

# WHERE clause with exclusion

I have the folowinf table, can someone tell me how do I get all score greater than or equals 17 (excluding Clurse_ID=Eng). I mean observations where Course_ID=Eng should not be in considered in this clause. Thanks.

``````DATA Apple.have;
input Student_ID \$ Course_ID \$ Score;
cards;
F103 Bio 18
F103 Math 15
F103 Eng 16
F103 Che 15
F103 Math 20
F103 Phy 17
M101 Eng 20
M101 Bio 20
M101 Eng 10
M101 Math 18
RUN;
``````

Output table:

``````F103 Bio 18
F103 Eng 16
F103 Math 20
F103 Phy 17
M101 Eng 20
M101 Bio 20
M101 Math 18``````

Accepted Solutions
Solution
‎11-17-2016 07:47 AM
Posts: 1,837

## Re: WHERE clause with exclusion

``````DATA Apple.have;
input Student_ID \$ Course_ID \$ Score;if score ge 17 or course_id eq 'ENG';

All Replies
Solution
‎11-17-2016 07:47 AM
Posts: 1,837

## Re: WHERE clause with exclusion

``````DATA Apple.have;
input Student_ID \$ Course_ID \$ Score;if score ge 17 or course_id eq 'ENG';
Occasional Contributor
Posts: 9

## Re: WHERE clause with exclusion

DATA WANT;
SET Apple.HAVE (WHERE =(Score >= 17 or Course_ID = 'Eng' ));
RUN;

Result :

The observation 7 is also included

Obs Student_ID Course_ID Score

1 F103 Bio 18
2 F103 Eng 16
3 F103 Math 20
4 F103 Phy 17
5 M101 Eng 20
6 M101 Bio 20
7 M101 Eng 10
8 M101 Math 18

Super User
Posts: 23,778

## Re: WHERE clause with exclusion

monikka1991_gmail_com wrote:

Result :

The observation 7 is also included

Sorry, what are you trying to say here?

Obs 2 & 7 would be excluded otherwise, but they're included because Course_ID="ENG"

Occasional Contributor
Posts: 9

## Re: WHERE clause with exclusion

Yeah ..But mlogan desired output has not included the 7th observation [7 M101 Eng 10] . I just added that note .

Super User
Posts: 23,778

## Re: WHERE clause with exclusion

Ah, you're correct, good catch!

But my guess is its an oversight on @mlogan part. I guess he can respond either way!

☑ This topic is solved.