Help using Base SAS procedures

Convert string datetime to iso8601

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Convert string datetime to iso8601

Dear all.

I-m very newbie to sas and I`m getting crazy with a simple problem.

I have a variable in a dataset $25. that contains a date like 18MAR2014:11:19:42

I want to convert it in a iso8601dt format...

Using

put _datetime is8601dt.;

I get in log

put _datetime is8601dt.;

                    ---------

                    48

ERROR 48-59: The format $IS8601DT was not found or could not be loaded.

Could you please help me?

SAS 9.3

Thank you

KR


Accepted Solutions
Solution
‎09-02-2014 06:34 AM
Super User
Super User
Posts: 7,988

Re: Convert string datetime to iso8601

Well, its a process of reading the string in as the nearest date/time format, then just apply a format:

data a;

  a="18MAR2014:11:19:42";

  b=input(a,datetime19.);

  format b e8601dt.;

run;

View solution in original post


All Replies
Super Contributor
Posts: 308

Re: Convert string datetime to iso8601

Occasional Contributor
Posts: 9

Re: Convert string datetime to iso8601

Thank you Loko,

but i cannot find any example to convert string into iso format.

Could you please provide an example to convert String in to iso8601...

I can also use date and time variables to convert into iso8601...


Thank you!

Solution
‎09-02-2014 06:34 AM
Super User
Super User
Posts: 7,988

Re: Convert string datetime to iso8601

Well, its a process of reading the string in as the nearest date/time format, then just apply a format:

data a;

  a="18MAR2014:11:19:42";

  b=input(a,datetime19.);

  format b e8601dt.;

run;

Super Contributor
Posts: 308

Re: Convert string datetime to iso8601

As RW9 stated - you just have to choose the appropriate format (you can find them at the link mentioned in my previous post). Ther is no format named iso860 within SAS .

Occasional Contributor
Posts: 9

Re: Convert string datetime to iso8601

thank you everybody.

it works!!

Thanks RW9 for the working example

🔒 This topic is solved and locked.

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

Discussion stats
  • 5 replies
  • 1533 views
  • 3 likes
  • 3 in conversation