Exampler.org SAS PYTHON HTML
SAS Introduction
SAS Abs
SAS Anydigit
SAS ASC
SAS Case Stmnt.
SAS Ceiling
SAS Change type
SAS Char
SAS CMISS
SAS Coalesc
SAS Coalescec
SAS Concatenate
SAS Constant
SAS Create Table
SAS DateTime
SAS Day
SAS Find
SAS Floor
SAS HMS
SAS Holiday
SAS HOUR
SAS Import
SAS Informats
SAS Inobs
SAS Input Stmt.
SAS Int
SAS INTNX
SAS Length
SAS Libname
SAS Loops
SAS Minute
SAS Month
SAS MDY
SAS NMISS
SAS Notdigit
SAS Lowercase
SAS Outobs
SAS Put Stmt.
SAS Rename
SAS Round
SAS Scan
SAS Substr
SAS Sum
SAS STNAME
SAS STNAMEL
SAS Time
SAS Trunc
SAS Uppercase
SAS Week
SAS Year
SAS Financial Functions
SAS Compound

SAS Date Time

What is it?

Syntax:

  • datetime();

SAS Date Time:


 SAS Date Time Example:




Data work.my_data_file;

    Result_1 = Datetime();
    Result_2 = PUT(Result_1, nldatm.);

Run;





What's happening in the script above?

  • The DateTime(); Function is calculating the number of seconds from January 1st 1960 to the current date time
  • The PUT(); Function is converting the supplied Datetime in seconds (1934061623.7) to something readable 14Apr2021:23:20:24


Date Time Example:

Variable Input Output Description
Result_1 Datetime(); 1934061623.7 SAS seconds through April 14th 2021 at 11:20:24
Result_2 Put(1934061623.7, nldatm.) 14Apr2021:23:20:24 Re-Formatted seconds value to a human readable date

See also; PUT Function

See also; TODAY Function

See also; MYD Function

Connect via LinkedIn

Kevin Regan

Have an article, idea, found a typo, want to contribute? Shoot me an email Here


Below are links to some Udemy Data Science Courses. I've been using Udemy for a number of years now, and I've found their courses super helpful, maybe you will also.