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

I have been using the same code and data source to run weekly reports without any issues using, however, this week one of my date columns will not import from Excel. The variable 'collectiondate' is formatted as Date in Excel but when it imports to SAS the entire column of data is missing and the informat and format of the column are TIME8. instead of the preferred DATE9. format that I have been using. It shows up the same way in all four of the data sets created. Any idea why this would be happening all of a sudden and ideas on how to fix it? I had been using 9.3 but recently switched to 9.4 if that makes any difference. Screenshots and code below.

 

Excel screenshot.png

 

SAS screenshot.png

 

 

OPTIONS MPRINT;

%MACRO IMP(INSHEET=);
PROC IMPORT OUT=WORK.&INSHEET
      DATAFILE="filepathway...\NHSN_LTCF_covid19 &extract_date..xlsx"
      DBMS=EXCEL REPLACE;
      SHEET="&INSHEET.$";
      GETNAMES=YES;
      MIXED=NO;
      SCANTEXT=YES;
      USEDATE=YES;
      SCANTIME=YES;
RUN;

%MEND IMP;

%IMP(INSHEET=covid19res);
%IMP(INSHEET=covid19staff);
%IMP(INSHEET=covid19supp);
%IMP(INSHEET=covid19vent);
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Try using XLSX instead to import your data but using Excel means you have limitations on the control of the type of data you're importing. In the long it would be best to change your data format to a CSV.

PROC IMPORT OUT=WORK.&INSHEET
DATAFILE="filepathway...\NHSN_LTCF_covid19 &extract_date..xlsx"
DBMS=XLSX REPLACE;
SHEET="&INSHEET.$";
GETNAMES=YES;

RUN;

View solution in original post

2 REPLIES 2
Reeza
Super User
Try using XLSX instead to import your data but using Excel means you have limitations on the control of the type of data you're importing. In the long it would be best to change your data format to a CSV.

PROC IMPORT OUT=WORK.&INSHEET
DATAFILE="filepathway...\NHSN_LTCF_covid19 &extract_date..xlsx"
DBMS=XLSX REPLACE;
SHEET="&INSHEET.$";
GETNAMES=YES;

RUN;
wml_3
Fluorite | Level 6

This solved the problem on the data not entering - thanks! Had to take a few more steps to get it into the correct format but at least I can work with it now.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1465 views
  • 2 likes
  • 2 in conversation