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

Reading Date and Datetime Values with Informats

The SAS System provides a selection of informats for reading SAS date and datetime values from date and time values recorded in ordinary notations.

A SAS informat is an instruction that converts the values from a character string representation into the internal numerical value of a SAS variable. Date informats convert dates from ordinary notations used to enter them to SAS date values; datetime informats convert date and time from ordinary notation to SAS datetime values.

For example, the following SAS statements read monthly values of the U.S. Consumer Price Index. Since the data are monthly, you could identify the date with the variables YEAR and MONTH, as in the previous example. Instead, in this example the time periods are coded as a three-letter month abbreviation followed by the year. The informat MONYY. is used to read month-year dates coded this way and to express them as SAS date values for the first day of the month, as shown in the following instream data:

   data uscpi;
      input date: monyy7. cpi;
   datalines;
   jun1990 129.9
   jul1990 130.4
   aug1990 131.6
   sep1990 132.7
   oct1990 133.5
   nov1990 133.8
   dec1990 133.8
   jan1991 134.6
   feb1991 134.8
   mar1991 135.0
   apr1991 135.2
   may1991 135.6
   jun1991 136.0
   jul1991 136.2
   ;

The SAS System provides informats for most common notations for dates and times. See Chapter 3 for more information on the date and datetime informats available.

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

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