SAS 9.3 DATETIME VARIABLE FORMAT AS DATE

后端 未结 8 1548
误落风尘
误落风尘 2020-12-18 16:36

I have a datetime22.3 variable which I would like to display as date.

for eg I want to display 17JUL2006:00:00:00.000 as 07/17/2006

How do I do this?

8条回答
  •  情书的邮戳
    2020-12-18 17:14

    My answer from a duplicate question:

    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.abc2
     as select *, DATEPART(a.Billing_Dt) format ddmmyy10. as Bill_date
    from abc;
    quit;
    

    So the point is, as Keith pointed above, to apply appropriate type of format (e.g. ddmmyy10. is the SAS Date format) to appropriate values = variable content (e.g. (unformatted) 10 is 11th January 1960 if used as date, while it's 01JAN60:00:00:10 if used as Datetime value), so you have to be sure what your values represent and convert the values if needed.

提交回复
热议问题