Solved
Contributor
Posts: 73

# How to read yyyymmddhmmss informat

Hello Expert,

I have a character column  which is containing records in yyyymmddhmmss format.

Data Test;

Length A \$60.;

A='20180205092045';

B=input(A,informat);

run;

Regards,

Ritesh

Accepted Solutions
Solution
‎02-08-2018 06:39 AM
PROC Star
Posts: 549

## Re: How to read yyyymmddhmmss informat

something like

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

All Replies
Moderator
Posts: 329

## Re: How to read yyyymmddhmmss informat

``````Data Test;

Length A \$60.;

A='20180205092045';

B=input(A,anydtdtm.);

run;``````
Contributor
Posts: 73

## Re: How to read yyyymmddhmmss informat

its not reading in anydtdtm. informat.
I want my data in datetime20.6 format.
Solution
‎02-08-2018 06:39 AM
PROC Star
Posts: 549

## Re: How to read yyyymmddhmmss informat

something like

``````Data Test;
A='20180205092045';
B=input(A, B8601DJ16.);
format B datetime20.;
run;``````
Contributor
Posts: 73

## Re: How to read yyyymmddhmmss informat

Thanks Its working

Contributor
Posts: 40

## Re: How to read yyyymmddhmmss informat

Data Test;

Length A \$60.;

A='20180205092045';

B=input(A,anydtdte14.);

run;

Super User
Posts: 10,571

## Re: How to read yyyymmddhmmss informat

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;``````

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