BookmarkSubscribeRSS Feed
kiddcao
Calcite | Level 5

I imported 5 excel files into SAS and there are some dates formatted as 8/3/1989 originally and formatted into 03Aug1989 (DATE9.) which is what I really want. However, on 1 file the dates failed to converted into DATE9. and it is read as $CHAR10 when I read the log. I tried several ways to reformat it into DATE9 but failed.

  1. I tried to change all informat/format/input into DATE9. instead of $CHAR10 but failed, the results are all empty (.)
  2. I tried  DateNew=input (Date,DATE9.);   but it didn't work either.

Any comment?

Thanks!

2 REPLIES 2
Reeza
Super User

Your second method should be correct.

One thought is trailing spaces so perhaps a compress or trim might help?

DateNew=input (compress(Date),DATE9.);

ballardw
Super User

HOW did you get the data from Excel? Proc Import has a number of issues with Excel depending on what people put in the Excel file.

Also, look at the cell level formats in Excel. If they were set as character and the value entered as text '8/3/1989 they would likely come in as text.

If the values are 8/3/1989 then you want to use

DateNew = input(date, mmddyy10.);

and

Format DateNew date9.;

when use input(date,date9.) SAS expects the text value to look like 03Aug1989 not 8/3/1989.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 836 views
  • 0 likes
  • 3 in conversation