BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ljlynn97
Fluorite | Level 6

I am trying to import data using proc import and having trouble with a date format. In Excel the date appears as MM/DD/YYYY but when I run the import, I get a 5-character string that does *not* correspond to the SAS date (e.g. the date is 10/08/2019, and after the import the cell shows "43745", which, even if I convert it to a date, is equivalent to 10/08/2079).

 

Is there a way I can specify in the proc import how I want to import this particular column?

 

proc import
	out=data_collected
	datafile="SchoolList.xlsx"
	DBMS=XLSX
	replace
	;
	range="'School_Data'$A:K";
run;

ljlynn97_0-1595366699947.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
smantha
Lapis Lazuli | Level 10

The date you are getting is an excel representation of the date which starts from 1 under 1JAN1900. Even though they are displayed as dates excel is storing them as numbers underneath. You can fix your excel sheet not to do that by playing around with date formats, or subtract 21916, from the number you get after reading into sas, and format the number as a date.

View solution in original post

2 REPLIES 2
smantha
Lapis Lazuli | Level 10

The date you are getting is an excel representation of the date which starts from 1 under 1JAN1900. Even though they are displayed as dates excel is storing them as numbers underneath. You can fix your excel sheet not to do that by playing around with date formats, or subtract 21916, from the number you get after reading into sas, and format the number as a date.

ljlynn97
Fluorite | Level 6

This makes sense. The Excel sheet is fixed but I can subtract 21916 when I do some other data cleanup. Thank you!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 3828 views
  • 1 like
  • 2 in conversation