Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Dates and if/then else

Dates and if/then else

Dates and if/then else

Good afternoon,
In a nutshell: we have a date range of 01/01/2011 and 01/31/2011.  If the date in the Due date column is in the rnage the new date should be 12/31/2010.
We've tried these three if/then steps so far with no luck:
IF ' 01/01/2011'>=FAKE_DT<= ' 01/31/2011 ' then put ' 12/31/2010'; else

if CE_DUE_DT  >= 18628 and CE_DUE_DT <= 18658 then CE_DUE_DT = 18627; else

If 18628 >=FAKE_DT<=18658 then CE_DUE_DT = 18627; else

Basically...the new CE Due Dt needs to be the last day of the previous month.

Can anyone help?

RE: Dates and if/then else

If CE_DUE_DT has to always be the last day of the previous month (relative to the date being passed to it), I would recommend using the Intnx function to get the first day of that month and subtract 1 to get the last day of the previous month.



data _null_ ;
   date = '01SEP10'd ;
   lastDay = intnx('month',date,0,'B')-1 ;
   format date lastday date9. ;
   put _all_ ;
   run ;

Here's a few examples of finding whether a date is in a range (I would suggest putting the dates into variables, or using the 'd to make the code more human readable).


data _null_ ;
   fromDt = '01SEP10'd ;
   toDt   = '30SEP10'd ;
   dummy  = '15SEP10'd ;
   if fromDt <= dummy <= toDt           then put 'Y';else put 'N' ;
   if dummy >= fromDt and dummy <= toDt then put 'Y';else put 'N' ;

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close