DATA Step, Macro, Functions and more

how can i do this for next 5 years !!

Reply
Frequent Contributor
Posts: 97

how can i do this for next 5 years !!

hi,

I am increementing 'spcday' by one month.....as  ' nxt_spcday'.....but while increementing "nxt_spcday' should not a 'SUNDAY'

Till now i did only for one month....how can do this for next 5 years ...?

data have ;

input scheme$ spcday DDMMYY10.;

nxt_spcday=intnx('month',spcday,1,'s');

if weekday(nxt_spcday)=1

then nxt2_spcday=intnx('day',nxt_spcday,1);

FORMAT spcday DDMMYY10. ;

format nxt_spcday ddmmyy10.;

format nxt2_spcday ddmmyy10.;

datalines;

IV 14/03/2013

;

Regards

ALLU

Respected Advisor
Posts: 4,919

Re: how can i do this for next 5 years !!

Posted in reply to allurai0412

Try something like this :

data have;

format spcday nxt_spcday ddmmyy10.;

input scheme$ spcday DDMMYY10.;

do _n_ = 1 to 5*12;

     nxt_spcday=intnx('month',spcday,_n_,'s');

     if weekday(nxt_spcday)=1

          then nxt_spcday=intnx('day',nxt_spcday,1);

     output;

     end;

datalines;

IV 14/03/2013

;

PG

PG
Frequent Contributor
Posts: 97

Re: how can i do this for next 5 years !!

Thanks a lot..

Ask a Question
Discussion stats
  • 2 replies
  • 179 views
  • 4 likes
  • 2 in conversation