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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.