DATA Step, Macro, Functions and more

Getting a date in the future

Reply
N/A
Posts: 0

Getting a date in the future

Hi All

How do I go about getting a data in the future and assigning this to a value. For example, I have to read in a list of value, e.g. A1, A2, A3 - each of these will have different due terms - e.g. A1 = Payable in 1 mth on the 25th, A2 = Payable in 2 mth on the 25th etc

So, how do I get the 25th of the following TWO and THREE months to assign to a value. I was thinking of using INTX function but don't that will work.

Thanks for your help.
Shelton.
Valued Guide
Posts: 634

Re: Getting a date in the future

Posted in reply to deleted_user
INTNX should do the trick. One solution might be something like:

[pre]
data adv;
date=today();
a1=1; a2=2; a3=3;
adv1 = intnx('month',date,a1)+24;
adv2 = intnx('month',date,a2)+24;
adv3 = intnx('month',date,a3)+24;
run;
[/pre]
Super User
Posts: 10,028

Re: Getting a date in the future

Posted in reply to deleted_user
Hi. INTX function has the fourth argument 'sameday' can obtain the same day after two or three months.

followdate = intnx('month',A1,2,'sameday');
N/A
Posts: 0

Re: Getting a date in the future

Posted in reply to deleted_user
thanks all for your help - I did the following:

IF NPAYTERM = 'A1' THEN DO;
NEXT_MON=INTNX('MONTH',DOCDATE,1) + 24;
R3DUED=PUT(NEXT_MON,YYMMDD10.);
SUBSTR(R3DUED,5,1) = '-';
SUBSTR(R3DUED,8,1) = '-';
PUT R3DUED;
END;

ELSE IF NPAYTERM = 'A2' THEN DO;
TWOMONTS=INTNX('MONTH',DOCDATE,2) + 24;
R3DUED=PUT(TWOMONTS,YYMMDD10.);
SUBSTR(R3DUED,5,1) = '-';
SUBSTR(R3DUED,8,1) = '-';
PUT R3DUED;
END;

etc etc

Thanks again.
Valued Guide
Posts: 634

Re: Getting a date in the future

Posted in reply to deleted_user
To show a dash as the separator consider the format yymmddd10. (notice the third d).

If all you want to do is write the value to the LOG, then you can avoid creating the variable R3DUED by using this format in the PUT statement.
[pre]
put next_mon yymmddd10.;
[/pre]

I always try to second guess the need to create a date stored in a character variable.
Ask a Question
Discussion stats
  • 4 replies
  • 138 views
  • 0 likes
  • 3 in conversation