BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Hari2
Quartz | Level 8

Hi All,

 

- I have Imported data from Excel file in which I have a column with both date and time Ex: 05/09/2018 9:46. (dd/mm/yyyy hh:mm)

 - I am using ANYDTDTM. to convert it to datetime format and the code I am using is Below.

   input(coll_date_time,ANYDTDTM.) as erdttime format=datetime15.

 

- Here, we have dates in the form of dd/mm/yyyy hh:mm and expectation from above piece of code is 05SEP18:09:46. However, above code is giving output as '09MAY2018:09:46'. It's considering day as month and Month as Day.

while the same code is giving correct Output for ''29/01/2019 10:40" as 29JAN19:10:40 (here its considering correctly when day is above 12) .

 

Please provide what should I specify here to get correct output as required. Thanks for your support in advance.

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

You need to properly set your DATESTYLE= system option. Or you input date and time separately (use the SCAN() function to get the parts) and combine them with DHMS().

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

You need to properly set your DATESTYLE= system option. Or you input date and time separately (use the SCAN() function to get the parts) and combine them with DHMS().

Hari2
Quartz | Level 8
Thank you Sir.. I used DATESTYLE Option.. 🙂
Kurt_Bremser
Super User

Personally, I prefer to not use the "any" informats, as they might read something without ERROR that is in fact not correct. I try to force the correct informat as much as I can, so that I get alerted to data mistakes by a crashing import job (because I am responsible for ~1000 batch jobs, several hundred of which are pure import jobs, and I cannot check that manually).

Some of those imports read data that was handled manually on the way, and must be considered unreliable and therefore checked for correctness as much as possible.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1375 views
  • 1 like
  • 2 in conversation