09-30-2016 06:52 PM
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:MMS'. 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:
%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!
09-30-2016 07:54 PM
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.
10-03-2016 10:30 AM
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.