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

## Mathematical Comparison Operators

Hi....I am trying to delete records when the Withdrawn Date is "less then" the Term Start Date. The code below gives me the right output. Can anyone explain to me why the ">" in this context is referring to "less than". Thanks

```data Want;
set Have;
if 'Withdrawn Date'n > 'Term Start Date'n then delete;
run;```
1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: re: Mathematical Function

Remember you're deleting records that MATCH your condition.
So anything left in the data set is the OPPOSITE of the comparison.
8 REPLIES 8
Super User

## Re: re: Mathematical Function

Because > is read "greater than" from left to right.

"Less than" would look like

`if 'Term Start Date'n < 'Withdrawn Date'n  then delete;`

A way to remember the "wide" end of the > or the < is the "Larger" value when true.

Super User

## Re: re: Mathematical Function

Maybe your logic is backwards. Your code is deleting records where the withdrawn date is after the term start date. It may only work by accident....so I'd be double checking things.
Pyrite | Level 9

## Re: re: Mathematical Function

Hi....when I run the code below, I am getting all the records where the Withdrawn Date is LESS than the Term Start Date. But am I correct that the if statement is processed from left to right?

```data Want;
set Have;
if 'Withdrawn Date'n < 'Term Start Date'n then delete;
run;```
Super User

## Re: re: Mathematical Function

Remember you're deleting records that MATCH your condition.
So anything left in the data set is the OPPOSITE of the comparison.
Pyrite | Level 9

## Re: re: Mathematical Function

Hi...I was able to track down where the problem is. The missing entries in the Withdrawn Date variable has decimal rather than  blank space. I will double check where it has changed to decimal from a blank space. Thanks.

Super User

## Re: re: Mathematical Function

SAS shows numeric missing as a period, not as a blank space.
PROC Star

## Re: re: Mathematical Function

In your case it doesn't matter which direction you read your IF statement.

"Withdrawn Date < Term Start Date then delete" is equivalent to "Term Start Date > Withdrawn Date then delete"

The result set will be the same.

Super User

## Re: Mathematical Comparison Operators

FYI - I changed the subject line of your question, as you're really asking about mathematical comparison operators.
https://documentation.sas.com/doc/en/lrcon/9.4/p00iah2thp63bmn1lt20esag14lh.htm#n10lfrm906gpv7n1t7fu...
Discussion stats
• 8 replies
• 570 views
• 0 likes
• 4 in conversation