Richard
Richard

Reputation: 41

how to import sas datetime in the following format

I am trying to load a csv file contain a date-time variable. The variable looks like the following

datetime
2008-10-08T07:06:08.248635000Z
2008-10-08T07:06:09.613897000Z
2008-10-08T07:06:28.217422000Z
2008-10-08T07:07:53.461926000Z
2008-10-27T16:10:49.189132000Z

I tried format time18.3, but because there is a character T after the date and character Z after the time, so the importing is not successful. Could anyone teach me how to load this data please.

Upvotes: 0

Views: 453

Answers (1)

Joe
Joe

Reputation: 63424

That's B8601DZw.d format; so you can use B8601DZ30. I believe.

  data _null_;
    dt_char='2008-10-08T07:06:08.248635000Z';
    dt_num = input(dt_char,B8601DZ30.);
    put dt_num= datetime.;
  run;

Upvotes: 1

Related Questions