BookmarkSubscribeRSS Feed
Amali6
Quartz | Level 8

Hi,

Can someone say how many conditions are allowed to be given inside a where statement in the Proc step please?

 

Thanks in advance

5 REPLIES 5
Tom
Super User Tom
Super User

I doubt there is a design limit. There might be some physical limit it terms of memory usage or compile time.

ballardw
Super User

@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.

s_lassen
Meteorite | Level 14

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.

Amali6
Quartz | Level 8
Thank you. But can i ask you, whether sas accepts more than three conditions in the where statement?
ChrisNZ
Tourmaline | Level 20

>  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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 802 views
  • 1 like
  • 5 in conversation