Reputation: 489
Have string "09/07/2019 20:40:01 EDT"
Run command in SAS EG 7.1 connecting to a remote UNIX server
input(substr(event_time, 1, length(event_time)-4),anydtdtm23.) format DateTime23.3 as event_time
One machine comes back correctly as Sep 07, 2019. (dropping the time bit for clarity) The other machine comes back as July 09, 2019.
Based on what I've read in related questions it seems to be caused by locale setting
What governs SAS locale setting ? Is it my OS ? the Remote UNIX server ? Something in SAS EG settings ?
Thank you
Upvotes: 0
Views: 100
Reputation: 51621
Don't use a guessing procedure unless you must. The ANYDT... series of informats will assume that ambiguous MDY or DMY stings follow the custom of the current language settings of your SAS session. So if SAS thinks you are in England then '09/07/2019' looks like the 9th of July. But if you are in the US then it looks like September 7th.
Instead read the string using either the MMDDYY or DDMMYY informat, depending on what format the strings are actually stored in. If your source actually is using mixed month day ordering styles then write code that uses information from your data to pick the right informat for a particular observation instead of forcing SAS to use your session setting to decide which one to use.
Upvotes: 1