DATA Step, Macro, Functions and more

Conversion error datetime20.3 to yymmd7.

Accepted Solution Solved
Reply
Contributor JS
Contributor
Posts: 38
Accepted Solution

Conversion error datetime20.3 to yymmd7.

[ Edited ]

I'm trying to convert a datetime20. to a yymmd7. but I'm running into a peculiar error. The data steps run fine, the values get converted... but the error remains.

 

Any thoughts?

 

Thank you!

 

Code

data have;
input time datetime20.;
format time datetime20.;
informat time datetime20.;
cards;
12SEP2013:10:19:43
;
run;

data want;
set have;
format time datetime20. want_date yymmd7.;
want_date = input(datepart(time),yymmd7.);
run;

 

Error -- Informat could not be found 

485
NOTE 485-185: Informat YYMMD was not found or could not be loaded.

28 run;

NOTE: Numeric values have been converted to character values at the places given by: (Line)Smiley SadColumn).
27:19

 

Results -- Outputs and runs successfully despite error

time want_date
12Sep2013 10:19:43 2013-09

 

 


Accepted Solutions
Solution
‎02-08-2017 05:55 PM
Super User
Posts: 6,972

Re: Conversion error datetime20.3 to yymmd7.

You're overcomplicating things by a mile, and on the way you cause an unnecessary type conversion.

Do this instead:

want_date = datepart(time);
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎02-08-2017 05:55 PM
Super User
Posts: 6,972

Re: Conversion error datetime20.3 to yymmd7.

You're overcomplicating things by a mile, and on the way you cause an unnecessary type conversion.

Do this instead:

want_date = datepart(time);
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor JS
Contributor
Posts: 38

Re: Conversion error datetime20.3 to yymmd7.

I see. I was trying to re-input the date unnecssarily. This works beautifully. Thank you!

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 136 views
  • 1 like
  • 2 in conversation