Hi,
Can someone say how many conditions are allowed to be given inside a where statement in the Proc step please?
Thanks in advance
I doubt there is a design limit. There might be some physical limit it terms of memory usage or compile time.
@Amali6 wrote:
Hi,
Can someone say how many conditions are allowed to be given inside a where statement in the Proc step please?
Thanks in advance
I doubt that such a question arises without having a specific use issue. You might show the specific where that you attempted and discuss any issues.
A complex where clause will take you into the realm of truth tables and how to result the behavior of AND and OR bits of a statement.
There is a limit of one WHERE statement per proc or data step.
Only one. E.g.
proc print data=sashelp.class;
where sex='F' and age>14;
run;
has only one condition, which is compound.
You can use WHERE ALSO to expand on the initial condition, but that is just the same as using AND.
The code
proc print data=sashelp.class;
where sex='F';
where also age>14;
run;
gives the same result as the first example.
There are various limits to the length of conditions on different platforms.
For instance, some DBMS systems (possibly also SAS, I haven't checked) have a limit on the number of values you can put in an IN(...) condition. In the good old days a lot of work was done to get around this limitation in SAS/ACCESS to DB2, I think the limit was 1000 values at that time, and that was not always enough (there was no DBKEY data set option in SAS/ACCESS at that time, which would be the obvious solution today). Last time I hit this limit was on Oracle, I think it was 10000 values. But again, that may have changed now.
> can i ask you, whether sas accepts more than three conditions in the where statement?
Yes, there is not limit as was said above.
Can I ask you why you don't try rather than ask here? It would be much faster.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.