convert datetime to date in proc-sql sas

staq picture staq · Oct 13, 2014 · Viewed 51.1k times · Source

I'm trying to convert datetime22.3 variable to ddmmmyy10. in proc sql, this is giving me ****** in the output column.

How can I get the correct values in the output column?

Answer

vasja picture vasja · Oct 13, 2014

You need to convert original SAS DATETIME value (think of it as data type) to SAS DATE value using DATEPART() function and apply appropriate format:

proc sql; 
 create table work.abc 
 as select DISTINCT a.Account_Id,
  DATEPART(a.Billing_Dt) format ddmmyy10. as Bill_date
from abc table;
quit;