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

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Add your conditions as:

 

DATA Apple.have;
input Student_ID $ Course_ID $ Score;
if score ge 17 or course_id eq 'ENG';
cards;
.... your data ...
;
run;

View solution in original post

5 REPLIES 5
Shmuel
Garnet | Level 18

Add your conditions as:

 

DATA Apple.have;
input Student_ID $ Course_ID $ Score;
if score ge 17 or course_id eq 'ENG';
cards;
.... your data ...
;
run;
monikka1991
Obsidian | Level 7


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

Reeza
Super User

@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"

monikka1991
Obsidian | Level 7

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

Reeza
Super User

Ah, you're correct, good catch! 

 

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

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
  • 5 replies
  • 1836 views
  • 1 like
  • 4 in conversation