Desktop productivity for business analysts and programmers

SAS EG Text to Date Conversion

Accepted Solution Solved
Reply
Contributor
Posts: 70
Accepted Solution

SAS EG Text to Date Conversion

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?


Accepted Solutions
Solution
‎04-06-2013 05:23 PM
Super User
Super User
Posts: 6,842

Re: SAS EG Text to Date Conversion

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


All Replies
Solution
‎04-06-2013 05:23 PM
Super User
Super User
Posts: 6,842

Re: SAS EG Text to Date Conversion

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.

Contributor
Posts: 70

Re: SAS EG Text to Date Conversion

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 878 views
  • 0 likes
  • 2 in conversation