Hi All,
I just downloaded a file where I have the date with time in the format B8601DZ35. (variable name date_time)
The problem now is that I cannot really work with it. What I need is the date format as YYMMDD10. (Year-month-day) and the time as Hour:Minute:Second:Millisecond
The function year=year(date_time) etc but does not work.
I also tried :
data want; set have;
format date_time datetime26.;
put _all_ ;
run;
Also no effect.
How can I extract the individual values of the variable?
Thanks in advance!
Marc
Thanks Draycut.
I made it though with:
date = datepart(date_time); format date mmddyy10.; time = timepart(date_time);
Something like this?
data test;
x = "2018-07-07T08:15:09.0325056-05:00";
y = input(x, B8601DZ35.);
format y datetime26.;
put _all_ ;
run;
Thanks Draycut.
I made it though with:
date = datepart(date_time); format date mmddyy10.; time = timepart(date_time);
If you don't actually need the time part for anything consider:
data test; x = "2018-07-07T08:15:09.0325056-05:00"; y = input(x, yymmdd10.); format y yymmdd10.; run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.