BookmarkSubscribeRSS Feed
Scout
Calcite | Level 5

Hello,

I have imported an Excel (xlsx) dataset with 100+ variables, but one date variable refuses to be recognised as a date by SAS 9.4.  I have formatted it as a date in Excel, repeatedly done the 'text to columns' procedure to specify it is a date, and increased my guessingrows to well over the necessary amount.  I've also tried coping and pasting the values only in a new column, and repeated everything above, and still can't get it to work. 

I get  NOTE: Invalid numeric data, date='12/27/2016' , at line xxxx column x for every date entry.

 

I am unable to convert the file to CSV as I lose data in other columns (in other languages).  The Excel file has many date variables and I can get them all to work except this one.  I've also tried formatting the variable in SAS but just get errors that the format cannot be loaded (Date9. or anything else) despite working fine in other procedures. Any thoughts on what I can do?  

Thanks in advance

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Without seeing the file its going to be hard to help.  Excel is a terrible data medium.  One thing that jumps to mind is EU/US date differences for instance: MM/DD/YY and DD/MM/YY.

Is it possible that you have values in that column which could be interpreted either way?  Because 12/27/2016 would not be decodable to DD/MM/YY, but others might.  This might be confusing the "guessing" proc import program.  

Thats the only thing I can think off hand, however there could be any number of problems with an excel sheet - hidden things, hidden formats, differences in the data in each cell, just to name a few. Sounds like you have a real mess of a file.

If you can get the problem data, just a few rows, in a datastep (see: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...) then could suggest a input() function to convert it, as:

d_var=input(c_var,mmddyy10.);

Should work.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 2478 views
  • 0 likes
  • 2 in conversation