@PernilleBaekke wrote:
Hello,
I would like to convert a date from character to date format in SAS Enterprise Guide 7.1. I've used the format function:
data data1;
date_new=date_old;
format date_new date9.;
run;
however, when I do so, my date is changed from 11-06-2013 to 06-11-2013, which is not the same date.
11-06-2013 = 11Jun2013 (correct date)
06-11-2013 = 06Nov2013 (wrong date)
I hope you can help me.
Thank you!
So what should the "correct" date be for 06-11-2013? I believe you are implying without stating it that you also expect the second to be treated as 11Jun2013.
If you read both character values then SAS expects all of the values to be in either month-day-year or day-month-year order. The default depends on your national language settings as to whether month or day is the default for the first.
You do not show the code you used to convert a character to date. But with your given example I do not see how you know the second is "incorrect". If there is another variable that indicates some information then you can test that variable(or variables) and conditionally execute different INPUT statements or set a variable to the appropriate informat and use inputn.