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!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.