BookmarkSubscribeRSS Feed
LucianaPadua
SAS Employee

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

4 REPLIES 4
Vince28_Statcan
Quartz | Level 8

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

Vince28_Statcan
Quartz | Level 8

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

LucianaPadua
SAS Employee

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.

Vince28_Statcan
Quartz | Level 8

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 9342 views
  • 1 like
  • 2 in conversation