SAS 9.3 DATETIME VARIABLE FORMAT AS DATE

后端 未结 8 1544
误落风尘
误落风尘 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:07

    You can't apply a standard date format directly against a datetime value, although there are some date formats you can prefix with 'DT' which will display a datetime as a date. Unfortunately the MMDDYY format is not one of these, however you could use DTDATE9. which would format your datetime as '17JUL2006'.

    Another option is create your own format using the PICTURE statement, the example below will display the datetime as required.

    proc format;
    picture dtfmt low-high='%0m/%0d/%Y' (datatype=datetime);
    run;
    
    data want;
    dt_val='17JUL2006:00:00:00.000'dt;
    format dt_val dtfmt.;
    run;
    

提交回复
热议问题