Hello,
I'm trying to import a txt file with 3 datetime fields. The fields are ddmmyyyy hh:mm:ss and I can't find the informat corresponding to this one. I've tried with anydt but doesn't work.
Some fields are imported missing and many others wrong. For example 01/12/2012 09:24:54 is imported as 12Jan12 when it should be 1Dec...
Any suggestions?
thanks in advance.
Luciana
If anydt does read the value but fails to properly distinguish months from days, it likely has to do with your
DATESTYLE=
option. However, anydt. may or may not work with all datetime informats. Try
options DATESTYLE=dmy;
before your data step and see if it fixes your issue.
Vincent
options datestyle=dmy;
data have2;
input v1 anydtdtm.;
put v1 datetime18.;
datalines;
01/12/2012 09:24:54
;
run;
output to log is
01DEC2012:09:24:54
So it should solve your problem.
Vince
Thanks Vince.
I was trying to avoid a program task and use the import node, but I guess it's not going to be possible.
Hrm I'm not too familiar with what all options can be played directly with EG interface but here's an alternative that should allow you to only set the option and use the import interface as you did before
options ->custom code->insert custom sas code before task and query code (Check) -> edit...
type in a single line
options datestyle=dmy;
Save and then run whatever you were running.
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.