The intnx function increments dates by intervals.
intnx(interval, from, n <, alignment>)
interval is a character (e.g., string) constant or variable, from is the starting value (either a date or datetime), n is the number of intervals to increment, and alignment is optional and controls the alignment of the dates.
data temp2;
input id 1 @3 date mmddyy11.;
cards;
1 11/12/1980
2 10/20/1996
3 12/21/1999
;
run;
proc print data = temp2;
format date date9.;
run;
id date
1 12NOV1980
2 20OCT1996
3 21DEC1999
data temp3;
set temp2;
new_month = intnx('month',date,1);
run;
proc print data = temp3 noobs;
format date new_month date9.;
run;
id date new_month
1 12NOV1980 01DEC1980
2 20OCT1996 01NOV1996
3 21DEC1999 01JAN2000
No comments:
Post a Comment