Hello Expert,
Could you Please help me to read yyyymmddhmmss date value.
I have a character column which is containing records in yyyymmddhmmss format.
Please help me to read values.
Data Test;
Length A $60.;
A='20180205092045';
B=input(A,informat);
run;
Please let me which Informat can read it properly.
Regards,
Ritesh
something like
Data Test;
A='20180205092045';
B=input(A, B8601DJ16.);
format B datetime20.;
run;
Data Test;
Length A $60.;
A='20180205092045';
B=input(A,anydtdtm.);
run;
something like
Data Test;
A='20180205092045';
B=input(A, B8601DJ16.);
format B datetime20.;
run;
Thanks Its working
Data Test;
Length A $60.;
A='20180205092045';
B=input(A,anydtdte14.);
run;
I strongly advise against the use of the "any" informats. You just tell SAS to make a guess and create something out of a string that could contain absolute crap, and still end up with a non-missing value (and not even a NOTE!) that later wrecks all your analysis.
Force correct data at every step of your analytic chain, and never let the computer do your thinking for you. See Maxims 31 and 22.
Follow @kiranv_'s suggestion for using one of the ISO 8601 formats. I'd even use one for display:
Data Test;
A='20180205092045';
B=input(A, B8601DJ16.);
format B e8601dt19.;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.