SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Suzy_Cat
Pyrite | Level 9

 

Hi there,

 

Need advice on why the dates showing incorrect when exported to csv. The data looks absolutely fine in SAS but some random lines would show incorrect dates "mm/dd/yyyy" where it should be "dd/mm/yyyy". Most of the records still have correct date. It is really annoying. Hope some one can shed me some light here 🙂

 

in excel, the first line looks normal as 02/01/2018, but it is wrong, in SAS the correct date is 01 Feb 2018.

 

Capture1.JPG     

 

When this issue occurred, you can always found there are two sets of data there:

one is selectable by year/month/date, the other one can only be selected by the date itself.

 

Capture.JPG

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Excel is changing the datatype when you open it in Excel. To avoid this issue, open Excel, go to the Data tab>Import txt/CSV file. There's a button to say don't guess at types, select that and then format the data the way you need it.

Or export your data straight to Excel and it should avoid the issue altogether.

Or try changing the export format from SAS to be mmddyy as that's what Excel likes.

View solution in original post

4 REPLIES 4
Reeza
Super User
Excel is changing the datatype when you open it in Excel. To avoid this issue, open Excel, go to the Data tab>Import txt/CSV file. There's a button to say don't guess at types, select that and then format the data the way you need it.

Or export your data straight to Excel and it should avoid the issue altogether.

Or try changing the export format from SAS to be mmddyy as that's what Excel likes.
Suzy_Cat
Pyrite | Level 9
Thank for your help Reeza! I think I may got the right solution. I will test it tomorrow. Finger crossed!
Suzy_Cat
Pyrite | Level 9

Hi Reeza,

 

Thanks heaps for your help. You have pointed me out to the right direction.! How awesome is that... could not imagine if I don't have an answer to deal with the issue (was really annoying).

 

Now I have replaced all dates format from ddmmyy10. to date9. in SAS. Looks like the exported data are perfectly fine now in excel 🙂

 

 

Suzy_Cat
Pyrite | Level 9

Further more, in case any one may be interested, it is similar when using format mmyy5.(or mmyy7.)

I have found using format monyy7. is way more better if there is need to export to CSV/EXCEL.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1542 views
  • 5 likes
  • 2 in conversation