Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Working with Time Series Data

Computing the Width of a Time Interval

To compute the width of a time interval, subtract the ID value of the start of the next interval from the ID value of the start of the current interval. If the ID values are SAS dates, the width will be in days. If the ID values are SAS datetime values, the width will be in seconds.

For example, the following statements show how to add a variable WIDTH to the USCPI data set that contains the number of days in the month for each observation:

   data uscpi;
      input date date9. cpi;
      format date monyy7.;
      width = intnx( 'month', date, 1 ) - intnx( 'month', date, 0 );
   datalines;
   15jun1990 129.9
   15jul1990 130.4
   15aug1990 131.6
   15sep1990 132.7
    ... etc. ...
   ;

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.