Hello
May anyone explain why in the following query we get 5 rows.
The condition is :
where Gender="M";
where age>25;
Does it mean that the query is taking Males AND age>25?
In the result I see also Female.
Thanks
Yuli
Data Raw_tbl;
input name $ Gender $ age ;
cards;
Anna F 23
Ben M 25
Bob M 21
Brian M 27
Edward M 26
Emma F 32
Joe M 34
Sam F 32
Tom M 24
;
run;
data tbl2;
set Raw_tbl;
where Gender="M";
where age>25;
run;
In your example the second WHERE overwrites the first one. If you want both to be used (the equivalent of using an AND between them) do this:
data tbl2;
set Raw_tbl;
where Gender="M";
where also age>25;
run;
Always check your log.
If you do want both, add an SAME AND after the second WHERE, but before age.
Where same and age>25;
@Ronein wrote:
Hello
May anyone explain why in the following query we get 5 rows.
The condition is :
where Gender="M";
where age>25;Does it mean that the query is taking Males AND age>25?
In the result I see also Female.
Thanks
Yuli
Data Raw_tbl; input name $ Gender $ age ; cards; Anna F 23 Ben M 25 Bob M 21 Brian M 27 Edward M 26 Emma F 32 Joe M 34 Sam F 32 Tom M 24 ; run; data tbl2; set Raw_tbl; where Gender="M"; where age>25; run;
As I see there are 2 equivalent way:
where also age>25;
where same age>25;
Is there a difference between "SAME" and "ALSO"?
Use logical operands in your where clause:
where <condition> and/or <condition> and/or <condition>...;
I have never heard of, nor seen where also or where same being used.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.