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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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