Previous Page | Next Page

Working with Time Series Data

Reading Date and Datetime Values with Informats

SAS 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 follows:

data uscpi;
   input date : monyy7. cpi;
   format date monyy7.;
   label cpi = "US Consumer Price Index";
datalines;
jun1990 129.9
jul1990 130.4

   ... more lines ...   

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

Previous Page | Next Page | Top of Page