Sas Format Date
FORMATTING DATE
The Calendar Dates can be written in various formats .The different operations with dates require conversion of calendar date to sasdate and vice versa.

Calendar Date : Usual date formats (05/14/2005 , May 14,2005 , 14MAY2005 etc. )
Sasdate : Number of days between 01JAN1960 and a specified date.
CONVERT SASDATE TO CALENDAR DATE :
Case I:
Dates are given in this format:
John, 1-Jan-60
Mary, 11-Jul-55
Kate, 12-Nov-62
Mark, 8-Jun-59
SASCODE :
libname trial D:DateFormat;
data bdays;
infile D:DateFormatsampdata.csv dsd missover lrecl=20;
input name : $4.
bday : $char12.;
data newdt;
set bdays;
sasdate1=compress(bday,-);
newdate=input(sasdate1,date9.); /* CREATE SASDATE */
proc print data=newdt;
OUTPUT
Obs name bday sasdate1 newdate
1 John 1-Jan-60 1Jan60 0
2 Mary 11-Jul-55 11Jul55 -1635
3 Kate 12-Nov-62 12Nov62 1046
4 Mark 8-Jun-59 8Jun59 -207
If you dont mention the first two places of the year, by default it takes the nearest one to 1960.
The sasdate ‘newdate can be converted to different forms of calendar date.
Case II:
SASCODE :
data newdt1;
set newdt;
ndt1=put(newdate,mmddyy8.);
ndt2=put(newdate,mmddyy10.);
ndt3=put(newdate,mmddyy6.);
ndt4=put(newdate,mmddyy7.);
ndt5=put(newdate,date9.);

Get Your Essay

Cite this page

Convert Sasdate And Sas Format Date. (June 28, 2021). Retrieved from https://www.freeessays.education/convert-sasdate-and-sas-format-date-essay/