BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
EinarRoed
Pyrite | Level 9

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

1 ACCEPTED SOLUTION

Accepted Solutions
MarkJones
Obsidian | Level 7

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

2 REPLIES 2
Patrick_Tan
Fluorite | Level 6

Where is the WHERE used?

In a datastep, procs sql, other proc?

As a statement or dataset option?

MarkJones
Obsidian | Level 7

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

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