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):(Column).
27:19
Results -- Outputs and runs successfully despite error
time want_date
12Sep2013 10:19:43 2013-09
You're overcomplicating things by a mile, and on the way you cause an unnecessary type conversion.
Do this instead:
want_date = datepart(time);
You're overcomplicating things by a mile, and on the way you cause an unnecessary type conversion.
Do this instead:
want_date = datepart(time);
I see. I was trying to re-input the date unnecssarily. This works beautifully. Thank you!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.