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!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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