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
Add your conditions as:
DATA Apple.have; input Student_ID $ Course_ID $ Score;
.... your data ...
if score ge 17 or course_id eq 'ENG'; cards;
;
run;
Add your conditions as:
DATA Apple.have; input Student_ID $ Course_ID $ Score;
.... your data ...
if score ge 17 or course_id eq 'ENG'; cards;
;
run;
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
@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"
Yeah ..But mlogan desired output has not included the 7th observation [7 M101 Eng 10] . I just added that note .
Ah, you're correct, good catch!
But my guess is its an oversight on @mlogan part. I guess he can respond either way!
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.
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.