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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.