|<w.d>||Reads standard numeric data|
|<datew.>||Reads date values (ddmmmyy)/td>;|
|<$w.>||Reads standard character data|
|<$VARYINGw>||Reads character data of varying length|
SAS represents a date internally as the number of days
between January 1, 1960 and the specified date. Dates
before 1960 are represented with negative numbers. A
SAS date value is a numeric variable.
|SAS DateValue||Calendar DateValue|
|0||January 1, 1960|
|30||January 31, 1960|
|366||January 1, 1961|
|-365||January 1, 1959|
How do you use an InFormat to create a SAS date?
If the raw fields are aligned in columns, use formatted input and specify the informat.
e.g. input @1 visitdt yymmdd8.;
With list input, use a separate INFORMAT statement or a modifier.
input visitdt : yymmdd8.;
How do you refer to a particular date in SAS?
To create a SAS date constant, write the date enclosed in single or double quotes, followed by a D.
e.g. age = ’20-MAR-2012’d – incdt;
where visitdt lt “1may12”D;
How do you work with SAS date values?
When a variable is a SAS date value, you can easily apply operations such as addition and subtraction. To find the number of days between two dates, simply subtract the two SAS date variables.
e.g. daysbtwn = visitdt1 – visitdt2;
Comparison operators can also be used.
if visitdt1 <; visitdt2 then do;