SAS Date Function DHMS( )

. SAS DHMS( ) Function

SYNTAX: DHMS(sasdate,Hour,Minute,Second);

DHMS() is yet another date function simple and useful.

One can specify the date and time in HH, MM, SS format and DHMS( ) converts it into the time stamp value.

This function is basically useful when the SAS needs to update the table lying in external DBMS and the column format specified DBMS table is time-stamp and the source data is only date.

In this scenario DHMS( ) is supplied with ‘0’ as HH, MM, SS values and convert the date into time stamp.

This has been demonstrated below;

Example: SAS DHMS( ) Function

SAS Code:

PROC PRINT OUTPUT :

data temp;

dt1 = DHMS('21JAN2011'd,0,0,0);

dt2 = DHMS('17DEC2010'd,23,59,59);

run;

proc print data = temp;

format dt2 datetime25.6;

run;

Obs

1

dt1

1611187200

dt2

17DEC2010:23:59:59.000000

* Please note this code has compiled on SAS 9.2 Platform.

It is worth to note the format applied to dt2 in print procedure and hence the corresponding output; while dt1 has been saved in numeric format.