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

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

1 ACCEPTED SOLUTION

Accepted Solutions
sh0e
Obsidian | Level 7

@Kurt_Bremser 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

6 REPLIES 6
PGStats
Opal | Level 21

What evidence do you have that it is doing that?

PG
sh0e
Obsidian | Level 7

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.

PGStats
Opal | Level 21

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
Kurt_Bremser
Super User

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.

sh0e
Obsidian | Level 7

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

PGStats
Opal | Level 21

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 6 replies
  • 911 views
  • 0 likes
  • 3 in conversation