/* We have seen previously that SAS needs to use specific input formats if the data (both numeric and character) are in a "non-standard" form. Specifically, we have seen that including commas in numeric data requires using a comma informat and we have used the $w. informat to read character data having a length of more than 8 characters. SAS can also read and write dates and times in many different formats. These date and time values are stored internally as numeric data. Dates are represented as the number of days from January 1, 1960. This date would be stored as 0, while December 31, 1959 would be stored as -1. Times are stored as the number of seconds from midnight. A combination date and time is stored as the number of seconds from midnight of January 1, 1960. By storing dates and times as numeric data, we can do mathematical operations on them, such as subtracting one date from another to get the number of days between them. The following give examples of using date and time informats (formats used during input) and formats (used for output). */ options ls=100; filename foo URL "http://www.uvm.edu/~abh/stat295/datasets/dates.dat"; data dates; infile foo; input date1:date9. date2:mmddyy10. date3:ddmmyy10.; run; proc print; title "Dates without formats"; run; proc print data=dates; format date1 date9. date2 weekdate30. date3 worddate25.; title "Dates"; run; filename foo2 URL "http://www.uvm.edu/~abh/stat295/datasets/datetimes.dat"; data datetimes; infile foo2; input datetime1:datetime18. @21 date2 mmddyy10. @32 time2 time8. @42 date3 ddmmyy10. @53 time3 time8.; datetime2 = dhms(date2,hour(time2),minute(time2),second(time2)); datetime3 = dhms(date3,hour(time3),minute(time3),second(time3)); run; proc print; title "Dates and times without formats"; run; proc print; format datetime1 datetime2 datetime3 datetime20. date2 date3 date9. time2 time3 time10.; title "Dates and times"; run;