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: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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