BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Riteshdell
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
kiranv_
Rhodochrosite | Level 12

something like 

Data Test;
    A='20180205092045';
    B=input(A, B8601DJ16.);
    format B datetime20.;
run;

View solution in original post

7 REPLIES 7
AndrewHowell
Moderator
Data Test;

    Length A $60.;

    A='20180205092045';

    B=input(A,anydtdtm.);

run;
Riteshdell
Quartz | Level 8
its not reading in anydtdtm. informat.
I want my data in datetime20.6 format.
kiranv_
Rhodochrosite | Level 12

something like 

Data Test;
    A='20180205092045';
    B=input(A, B8601DJ16.);
    format B datetime20.;
run;
Riteshdell
Quartz | Level 8

Thanks Its working

srinath3111
Quartz | Level 8

Data Test;

Length A $60.;

A='20180205092045';

B=input(A,anydtdte14.);

run;

Kurt_Bremser
Super User

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;

 

AndrewHowell
Moderator
I wouldn't advocate the "any" informats in a critical operational environment. But the need which created the "any" informat highlights that there are inputs where we cannot mandate a consistent date/datetime informat. (That may or may not be the case here.)
Any use of an "any" informat MUST come with the presumption that the date might be incorrectly informatted.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1061 views
  • 4 likes
  • 5 in conversation