BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
csetzkorn
Lapis Lazuli | Level 10

I am using this code, which was originally generated in terms of the data formats using an import task:

 

DATA Bla;
    LENGTH
        Timestamp          8 ;
    FORMAT
        Timestamp        DATETIME18. ;
    INFORMAT
        Timestamp        DATETIME18. ;
    INFILE "&BaseFolder.&FileName2."
	        ENCODING="LATIN9"
	        TERMSTR=CRLF
	        DLM='09'x
	        MISSOVER
	        DSD 
			firstobs=2;
    INPUT
        Timestamp        : ?? ANYDTDTM19. ;
RUN;

Unfortunately, I now get errors  and funny entries like this:

 

 ******************

 

for source data like this:

 

31/05/2016 00:00:00

 

Can someone please advice how to potentially adjust the above formats? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

No problem, when using anydtdtm. instead of anydtdtm19.:

data work.forum;
   a = '31/05/2016 00:00:00';
   b = input(a, anydtdtm.);

   format b DATETIME18.;
run;

 

 

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

I'd read it into a character variable, convert the date and time parts separately (substr() and input() functions), and put together with result = date * 86400 + time.

andreas_lds
Jade | Level 19

No problem, when using anydtdtm. instead of anydtdtm19.:

data work.forum;
   a = '31/05/2016 00:00:00';
   b = input(a, anydtdtm.);

   format b DATETIME18.;
run;

 

 

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 608 views
  • 1 like
  • 3 in conversation