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?
Thanks.
additional info:
Thanks for all the replies.
Actually, I tried to output it in the date format within proc sql. The output is being printed as **********
(stars). I am not sure what is going on.
I am trying to use INTCK in the following manner but get error. I am not sure what I am doing wrong. I would appreciate your help. Thanks.
PROC FORMAT;
PICTURE DTFMT LOW-HIGH='%0m/%0d/%Y' (DATATYPE=DATETIME);
RUN;
data want;
dt_val1='17JUL2006:00:00:00.000'dt;
dt_val2='17AUG2012:00:00:00.000'dt;
format dt_val1 dt_val2 dt_val3 dtfmt.;
dt_val3=intck('MONTH',dt_val1,dt_val2);
put dt_val3;
run;
If you want to display the variable's contents as a date (without changing the underlying value), use a FORMAT statement.
etc. Note that you can also put the FORMAT in a data step, in which case any uses of the variable will automatically pick it up.
Converts date/time var to char date var:
Create numeric sas date without time:
Thanks to Rizier123 & Heemin posting above to the first portion.
use the same princpiple in a data step
This is the output from my SAS 9.3
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.