ISO date time format with missing time zone

Reply
Occasional Contributor
Posts: 8

ISO date time format with missing time zone

Hi All,

I have incoming date time as     '2012-04-05T-:-:-+00:00', with missing time zone represented with -, I am unable to convert it to datetime Numeric format.

But if I modify the date time as '2012-04-05T00:00:00+00:00' and use input(indate,e8601dz28.2); then it works.. May be I am not using the right informat..can anyone help?

Thanks,

R


PROC Star
Posts: 1,101

Re: ISO date time format with missing time zone

No, you are doing everything right with the informat.

The problem is that when you have the dashes in your first example, there is no way to know what time they represent, therefore no way to convert your character indate variable to a correct time. When you change the dashes to zeroes, you are changing the time values to midnight. Is that what you want if the hour, minute, and second are dashes?

Tom

Occasional Contributor
Posts: 8

Re: ISO date time format with missing time zone

Thanks Tom..

I remember reading in the SAS documentation that , SAS can read dashes(-) as missing values..

so ideally what I want is if the incoming dataset has dashes or zeros, SAS should be able to read them correctly and provide the non missing component of it..Is it possible?

so for firstcase '2012-04-05T-:-:-+00:00' output should be 5Apr12 and if there is a time present then show the time part as well..

If i give mydt = input('2012-10-9T-:-:-+00:00',e8601dz28.2); I get an error message..

Thanks..


PROC Star
Posts: 7,366

Re: ISO date time format with missing time zone

Do you need the time part?  If not, the following inputs just the dates:

data have;

  informat date B8601da.;

  format date date9.;

  input date score;

  cards;

2012-04-05T-:-:-+00:00  21

2012-04-05T00:00:00+00:00  22

;

Occasional Contributor
Posts: 8

Re: ISO date time format with missing time zone

Thanks Arthur..

I am getting error msg while running the code..

R

Respected Advisor
Posts: 3,124

Re: ISO date time format with missing time zone

Art's code runs fine on my 9.3, win7. What kind of error you are getting? can you post your log?

Haikuo

PROC Star
Posts: 7,366

Re: ISO date time format with missing time zone

The B8601da. informat was introduced in 9.2.  Are you on a version earlier than that?  Like Haikuo, I had tested it on 9.3.

Ask a Question
Discussion stats
  • 6 replies
  • 566 views
  • 3 likes
  • 4 in conversation