Task
Type of
Language
Element
Language
Element Input Result
DATETIME 1679097600 17MAR13:00:00:
00
Read datetime values as SAS
datetime values
Datetime
informats
DATETIME 17MAR13:00:00:00 1679097600
Return the current date and
time of day as a SAS
datetime value
Datetime
functions
DATETIME() () The SAS
datetime value at
the moment of
execution, in the
form
NNNNNNNNNN
.N.
Interval Tasks
Return the number of
specified time intervals that
lie between the two date or
datetime values
Interval functions INTCK week2
01aug60
01jan13
1368
Advances a date, time, or
datetime value by a given
interval, and returns a date,
time, or datetime value
Interval functions INTNX day
17mar12
365
19434
*
In SAS, a Julian date is a date in the form YYNNN or YYYYNNN, where YY is a two-digit year, YYYY is a four-digit year, and NNN
is the ordinal offset from January 1 of the year YY or YYYY. SAS processes Julian dates only for valid SAS dates.
SAS also supports these formats and informats:
ISO 8601 basic and extended forms for dates, times, datetimes, durations, intervals,
and time zones. For more information, see “Working with Dates and Times By Using
the ISO 8601 Basic and Extended Notations” in SAS Formats and Informats:
Reference and “Reading Dates and Times By Using the ISO 860 Basic and Extended
Notations” in SAS Formats and Informats: Reference.
International formats and informats that are equivalent to some of the most
commonly used English-language date formats and informats. For more information,
see “Dictionary of Formats for NLS” in SAS National Language Support (NLS):
Reference Guide and “Dictionary of Informats for NLS” in SAS National Language
Support (NLS): Reference Guide.
Examples
Example 1: Displaying Date, Time, and Datetime Values as
Recognizable Dates and Times
The following example demonstrates how a value might be displayed as a date, a time,
or a datetime. Remember to select the SAS language element that converts a SAS date,
time, or datetime value to the intended date, time, or datetime format. See the previous
tables for examples.
Note:
About SAS Date, Time, and Datetime Values 121
Time formats count the number of seconds within a day, so the values are
between 0 and 86400.
DATETIME formats count the number of seconds since January 1, 1960. For
datetimes that are greater than 02JAN1960:00:00:01 (integer of 86401), the
datetime value is always greater than the time value.
When in doubt, look at the contents of your data set for clues as to which type of
value you are dealing with.
This program uses the DATETIME, DATE, and TIMEAMPM formats to display the
value 86399 to a date and time, a calendar date, and a time.
options nodate;
data test;
Time1=86399;
format Time1 datetime.;
Date1=86399;
format Date1 date9.;
Time2=86399;
format Time2 timeampm.;
run;
proc print data=test;
title 'Same Number, Different SAS Values';
footnote1 'Time1 is a SAS DATETIME value';
footnote2 'Date1 is a SAS DATE value';
footnote3 'Time2 is a SAS TIME value';
run;
footnote;
Output 7.2 Datetime, Date, and Time Values for 86399
Example 2: Reading, Writing, and Calculating Date Values
This program reads four regional meeting dates and calculates the dates on which
announcements should be mailed.
data meeting;
input region $ mtg : mmddyy8.;
sendmail=mtg-45;
datalines;
N 11-24-12
S 12-28-12
E 12-03-12
122 Chapter 7 Dates, Times, and Intervals
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.174.0