BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
D_Z_
Obsidian | Level 7

Hi All,

I have a report that that i am importing to SAS in .csv format.  The date is in character format (Thu Apr 04 17:15:32 GMT 2013) and I need SAS to read this as a normal date time format.  The date and time are intermingled and I am not sure how to separate them and convert it to the proper date format.

I have been unable to find anything that will help me convert this.  I have tried many things... but the way the date comes out is odd and i can't get it convert over to datetime no matter what i do.  Does anyone know any tricks to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Can't you just convert it yourself?

Say it is read in as a character string named TIME.

datetime = input(scan(time,3)||scan(time,2)||scan(time,-1)||':'||scan(time,4,' '),datetime.);

format datetime datetime19.;

If all of the records do not say GMT then you will need add some logic to adjust for time zone.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Can't you just convert it yourself?

Say it is read in as a character string named TIME.

datetime = input(scan(time,3)||scan(time,2)||scan(time,-1)||':'||scan(time,4,' '),datetime.);

format datetime datetime19.;

If all of the records do not say GMT then you will need add some logic to adjust for time zone.

D_Z_
Obsidian | Level 7

Thank you for the help on this one.  If it were one or two entries i could most certainly converted them manually... however... i am dealing with thousands of entries per day, hence why i wanted SAS to do the converting for me.  I am not that great with these calculations, though i am getting better everyday.

Dean

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 1635 views
  • 0 likes
  • 2 in conversation