DATA Step, Macro, Functions and more

convert into is8601dt format

Reply
Contributor
Posts: 55

convert into is8601dt format

trying to convert sdtm date into is8601dt format in adam,not working,what I am missing?

TR02SDTM=input(EXSTDTC,is8601dt.);

dt.png

Super User
Posts: 10,279

Re: convert into is8601dt format

Use the e8601dt informat.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 55

Re: convert into is8601dt format

Posted in reply to KurtBremser
not workingSmiley Sad
Super User
Posts: 10,279

Re: convert into is8601dt format

Post the log, please. An some example data (see my footnotes for this).

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 55

Re: convert into is8601dt format

Posted in reply to KurtBremser

data exb1_;
24
25 set exb;
26 by usubjid;
27 if first.usubjid then do;
28 TR02SDT=input(EXSTDTC,e8601da.);
29
30 TR02SDTM=input(EXSTDTC,e8601dt.);
31 end;
32 if last.usubjid then do;
33 tr02edt=input(exendtc,e8601da.);
34 end;
35 format tr02sdtm e8601dt.;
36 format TR02SDT tr02edt e8601da.;
37 run;

NOTE: Invalid argument to function INPUT at line 30 column 13.

Super User
Posts: 10,279

Re: convert into is8601dt format

Use the

e8601dt16.

informat.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
PROC Star
Posts: 1,833

Re: convert into is8601dt format

I dont think there is an is8601dt informat to convert to a date numeric variable before you apply is8601dt  format 

You prolly need E8601DTw.d informat . Correct me if i am wrong

Community Manager
Posts: 3,440

Re: convert into is8601dt format

[ Edited ]
Posted in reply to novinosrin

I'm a little confused by your log and the format of the original values.  Doesn't something like this work?

 

data d;
 exstdtc = "2003-03-26T09:00";
 tr02sdtm = input (exstdtc,is8601dt.);
 format tr02sdtm is8601dt.;
run;
Valued Guide
Posts: 597

Re: convert into is8601dt format

[ Edited ]

unexpected leading or trailing blanks maybe causing the missing values. use COMPRESS() and check.

data test;
var1='		2003-03-26T09:00';
var2='2003-03-26T09:00';
need1=input(var1,is8601dt.);
need2=input(var2,is8601dt.);
run;

Capture.PNG 

Thanks,
Suryakiran
Contributor
Posts: 55

Re: convert into is8601dt format

Posted in reply to SuryaKiran

Thanks everyone.Problem was with blank space.

used tr02sdtm=input(strip(exstdtc),e8601dt.); and it worked

Ask a Question
Discussion stats
  • 9 replies
  • 159 views
  • 2 likes
  • 5 in conversation