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

Computing Calendar Variables from Dates

The functions YEAR, MONTH, DAY, WEEKDAY, and JULDATE compute calendar variables from SAS date values.

Returning to the example of reading the USCPI data from records containing date values represented in the MONYY format, you can find the month and year of each observation from the SAS dates of the observations using the following statements.

   data uscpi;
      input date monyy7. cpi;
      format date monyy7.;
      year  = year( date );
      month = month( date );
   datalines;
   jun1990 129.9
   jul1990 130.4
   aug1990 131.6
   sep1990 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.