SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Basic question about OR in a WHERE-statement

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

Basic question about OR in a WHERE-statement

For a where-statement, where I need to extract entries from three different months, should it work to use this?

&last_updated_month" EQ "&month1" | "month2" | "&month3"

Or, must I use this more convoluted version?

     (&last_updated_month" EQ "&month1") OR (&last_updated_month" EQ "month2") OR (&last_updated_month" EQ"&month3")

Sorry about the simple case question, but I don't have access to a historical data set to test it on now.

Thanks. Smiley Happy


Accepted Solutions
Solution
‎10-12-2012 05:09 AM
Occasional Contributor
Posts: 17

Re: Basic question about OR in a WHERE-statement

A simple way to do this (subject to the answer to Patrick's question) is to use the IN operator:

WHERE &last_updated_month IN ("&month1", "month2", "&month3")

which should boil down to doing exactly the same as your second syntax suggestion.  The first suggestion whilst it would be nice is not supported in SAS data steps

View solution in original post


All Replies
Occasional Contributor
Posts: 6

Re: Basic question about OR in a WHERE-statement

Where is the WHERE used?

In a datastep, procs sql, other proc?

As a statement or dataset option?

Solution
‎10-12-2012 05:09 AM
Occasional Contributor
Posts: 17

Re: Basic question about OR in a WHERE-statement

A simple way to do this (subject to the answer to Patrick's question) is to use the IN operator:

WHERE &last_updated_month IN ("&month1", "month2", "&month3")

which should boil down to doing exactly the same as your second syntax suggestion.  The first suggestion whilst it would be nice is not supported in SAS data steps

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 220 views
  • 0 likes
  • 3 in conversation