SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

import wizard informat DATETIME help

Occasional Contributor
Posts: 9

import wizard informat DATETIME help



I am using SAS9.4 an trying to import a csv file with the import wizard.


I am having difficulty with a date and time format. My data comes in with a date and time in the one cell in the format 'DD-MM-YYYY HH:MMSmiley FrustratedS'. I would like to continue working with it in this format, but am not sure whether SAS recognises it as date and time.


Here is the import wizard code (incomplete) I am currently using, but it imports the SET_DATE variable as a text:


%macro import(wk);
data WORK._&wk.;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile "C:\Users\Pete\Desktop\&wk..csv" delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ;
informat SORT_ID $10. ;
informat EVENT_ID $10. ;
informat SET_DATE $21. ;
format SORT_ID $10. ;
format EVENT_ID $10. ;
format SET_DATE best. ;


if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */


I have tried using ANYDTDTME21 and several other formats but am having trouble reading in that variable in a usable datetime format. Any help wold be great, thanks!

Super User
Posts: 17,912

Re: import wizard informat DATETIME help

Try an informat of anydtdm21 and a format of datetime21

Occasional Contributor
Posts: 9

Re: import wizard informat DATETIME help

Hi Reeza,


Thanks for the reply - that worked a charm.


I suspected it may have had something to do with inconsistency between the in/format aspect, but am evidently quite new to this.


Thanks for your help.



Super User
Posts: 10,538

Re: import wizard informat DATETIME help

Every so often, depending on the actual format of the text the ANYDTDTME works better as ANYDTDTME32. even though there are only 21 or other lower number of characters involved.

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation