Learning SAS? Welcome to the exclusive online community for all SAS learners.

DATE

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

DATE

Hello,

I am trying to import a date variable from a csv file:

 

input

date :ANYDTDTE9.;

format date Smiley Very HappyATE10.;

run;

 

However the results are incorrect, days, months and even years are being switched. Here are 3 examples:

CSV

12/06/2013 turns into 06DEC2013

23/07/2015 turns into 15JUL1923

03/12/2012 turns into 12MAR2012

 

Can anyone help resolve this error?

thanks

Sally

 

 


Accepted Solutions
Solution
‎05-26-2017 01:02 AM
Super User
Posts: 17,797

Re: DATE

When you use ANYDTDTE it guesses at the informat. It's easy to guess wrong with dates. 

 

Specify it explicitly instead, it looks like it should DDMMYY10. 

 

Please post your code using the insert code icons in the editor rather than directly in the forum. It gets garbled. 

Your format should be DATE9. 

 

View solution in original post


All Replies
Solution
‎05-26-2017 01:02 AM
Super User
Posts: 17,797

Re: DATE

When you use ANYDTDTE it guesses at the informat. It's easy to guess wrong with dates. 

 

Specify it explicitly instead, it looks like it should DDMMYY10. 

 

Please post your code using the insert code icons in the editor rather than directly in the forum. It gets garbled. 

Your format should be DATE9. 

 

Occasional Contributor
Posts: 9

Re: DATE

Thankyou!

Super User
Posts: 9,676

Re: DATE

options datestyle=dmy ;
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 249 views
  • 0 likes
  • 3 in conversation