ESmyth5988
ESmyth5988

Reputation: 518

SAS - custom date format

I'm trying to read in a date field that looks like:

Mar 20 2013 12:00AM

I am using the following user-defined date format and it is not working.

proc format;
    picture mydate other='%MON %0d %Y %0H:%0M %p' (datatype=datetime);
run;

data DATASET;
    infile CSVFILE 
    delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ;
    informat TestDate mydate. ;
    format TestDate mydate. ;
run;

Can anyone spot what is wrong with this? This is the first time I've needed to use a custom date format and I'm thinking I am missing something small. I am getting the following error:

NOTE: Informat MYDATE was not found or could not be loaded.

Upvotes: 1

Views: 536

Answers (1)

Joe
Joe

Reputation: 63424

I do not believe you can create INformats using Picture; only formats. (INformat = taking a string and converting to a (in this case) date value, format = taking a date value and converting to a string.)

Fortunately, ANYDTDTM. seems to read this in fine. (I changed to 11AM to make sure the time part was okay.)

data test;
input @1 x ANYDTDTM19.;
put x= DATETIME17.;
datalines;
Mar 20 2013 11:00AM
;;;;
run;

Upvotes: 4

Related Questions