Working with Time Series Data |
Computing the Ceiling of an Interval |
To shift a date to the start of the next interval if it is not already at the start of an interval, subtract 1 from the date and use INTNX to increment the date by 1 interval.
For example, the following statements add the variable NEWYEAR to the monthly USCPI data set. The variable NEWYEAR contains the date of the next New Year’s Day. NEWYEAR contains the same value as DATE when the DATE value is the start of year and otherwise contains the date of the start of the next year.
data test; set uscpi; newyear = intnx( 'year', date - 1, 1 ); format newyear date.; run;
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.