This is a response to SAS Tip: where also by @SAS_Tipster/@DonH since the topic is locked and replies are no longer allowed.
Is there a reason for using "also" over "and" in a where statement? Is one more efficient?
Usually this comes into play when you're possibly developing macros and you don't know how many conditions you may have. So its helpful to be able to create a line for each one with the ALSO without having to determine if you need an AND between each condition.
There are multiple ways to account for this, but this is a nice option.
@dgritt wrote:
This is a response to SAS Tip: where also by @SAS_Tipster/@DonH since the topic is locked and replies are no longer allowed.
Is there a reason for using "also" over "and" in a where statement? Is one more efficient?
Usually this comes into play when you're possibly developing macros and you don't know how many conditions you may have. So its helpful to be able to create a line for each one with the ALSO without having to determine if you need an AND between each condition.
There are multiple ways to account for this, but this is a nice option.
@dgritt wrote:
This is a response to SAS Tip: where also by @SAS_Tipster/@DonH since the topic is locked and replies are no longer allowed.
Is there a reason for using "also" over "and" in a where statement? Is one more efficient?
@dgritt wrote:
This is a response to SAS Tip: where also by @SAS_Tipster/@DonH since the topic is locked and replies are no longer allowed.
Is there a reason for using "also" over "and" in a where statement? Is one more efficient?
I suspect that the complier spends a little more time constructing an internal equivalent of the where statement using and with actual execution not varying much. But you could build a set and try that.
Coding styles would be the main reason I think. Some folks just plain don't like really long statements. I'm not quite in that group but I do pay attention to coding style with such things.
Where also would also allow for single * line comments to test/modify code that might take a bit more care with longer statements.
Reeza and ballardw beat me to it.
If if you look at the NOTE about the where clause, all of these variations produce the same note (for the sashelp.class data set):
So I suspect this is all reconciled at compile time.
I like option 3 for both the multiple clauses issue (also applies to stored processes with parameters for multiple conditions) as well avoiding the case where adding a where clause later can replace the existing one. The also clause is just a reminder to check if there is already an active WHERE for the step.
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.
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.