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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2222 views
  • 2 likes
  • 2 in conversation