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

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
Reeza
Super User
Remember you're deleting records that MATCH your condition.
So anything left in the data set is the OPPOSITE of the comparison.

View solution in original post

8 REPLIES 8
ballardw
Super User

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.

Reeza
Super User
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.
twildone
Pyrite | Level 9

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;
Reeza
Super User
Remember you're deleting records that MATCH your condition.
So anything left in the data set is the OPPOSITE of the comparison.
twildone
Pyrite | Level 9

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.

Reeza
Super User
SAS shows numeric missing as a period, not as a blank space.
SASKiwi
PROC Star

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.

 

Reeza
Super User
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...

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1287 views
  • 0 likes
  • 4 in conversation