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...

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 8 replies
  • 589 views
  • 0 likes
  • 4 in conversation