DATA Step, Macro, Functions and more

Why does SAS change the where-clause conjugates?

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

Why does SAS change the where-clause conjugates?

I have noticed that if my where clause looks something like this:

 

not( missing( ben_per_start_date ) | missing( ben_per_end_date ) )

 

SAS turns it into this logical equivalence

 

(not MISSING(ben_per_start_date)) and (not MISSING(ben_per_end_date)

 

Does this mean that I am coding my original incorrectly or inefficiently?

 

- Jack


Accepted Solutions
Solution
‎06-29-2016 03:33 PM
Contributor
Posts: 25

Re: Why does SAS change the where-clause conjugates?

Posted in reply to KurtBremser

@KurtBremser Are you writing that there are fewer comparisons using the AND operator because in the first expression is false, the second is not evaluated?

View solution in original post


All Replies
Esteemed Advisor
Posts: 5,535

Re: Why does SAS change the where-clause conjugates?

What evidence do you have that it is doing that?

PG
Contributor
Posts: 25

Re: Why does SAS change the where-clause conjugates?

That's what I posted.

 

The first piece of code is from the submitted SAS code.

 

The second piece of code was lifted from the SAS log.

 

Sorry if that wasn't clear.

Esteemed Advisor
Posts: 5,535

Re: Why does SAS change the where-clause conjugates?

For some obscure reason, SAS/SQL is very poor at handling OR operations. So, I guess it prefers the logical AND equivalent. Since both are logically equivalent, you should use the version that's clearer to you.

PG
Super User
Posts: 10,268

Re: Why does SAS change the where-clause conjugates?

When you have an and instead of an or, you can shortcut the condition when the first part is false. This reduces the overall amount of comparisons that must be made.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Solution
‎06-29-2016 03:33 PM
Contributor
Posts: 25

Re: Why does SAS change the where-clause conjugates?

Posted in reply to KurtBremser

@KurtBremser Are you writing that there are fewer comparisons using the AND operator because in the first expression is false, the second is not evaluated?

Esteemed Advisor
Posts: 5,535

Re: Why does SAS change the where-clause conjugates?

You could say the same thing of an OR operation. If the first operand is true, the second one doesn't need to be evaluated.

PG
🔒 This topic is solved and locked.

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

Discussion stats
  • 6 replies
  • 301 views
  • 0 likes
  • 3 in conversation