BookmarkSubscribeRSS Feed
saspert
Pyrite | Level 9

I am trying to run an import from excel into sas (using PC SAS 9.2). Although I did not develop the original code, it seems to be a fairly simple process. However, I am running into errors. Just want to run it by you and check if there is something that I am missing.

Code

%let mth=JUL;

libname  myxls1 "&path\Monthly_Summary_by_LATSK_In_Tran_In_Month_SK_GTET_&mth.2013.xlsx";

data &mth.2013;

    set myxls1.BO_Query;

run;

libname myxls1 clear;

Log

647  %let mth=JUL;

648  libname  myxls1 "&path\Monthly_Summary_by_LATSK_In_Tran_In_Month_SK_GTET_&mth.2013.xlsx";

NOTE: Libref MYXLS1 was successfully assigned as follows:

      Engine:        EXCEL

      Physical Name: C:\2013q3\Monthly_Summary_by_LATSK_In_Tran_In_Month_SK_GTET_JUL2013.xlsx

649  data &mth.2013;

650      set myxls1.BO_Query;

ERROR: File MYXLS1.BO_Query.DATA does not exist.

651  run;

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.JUL2013 may be incomplete.  When this step was stopped there were 0

         observations and 0 variables.

WARNING: Data set WORK.JUL2013 was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

652  libname myxls1 clear;

NOTE: Libref MYXLS1 has been deassigned.

Alternate Import code

PROC IMPORT OUT= &mth.2013 DATAFILE= "&path\Monthly_Summary_by_LATSK_In_Tran_In_Month_SK_GTET_&mth.2013.xlsx"

            DBMS=xlsx REPLACE;

     SHEET="BO_Query";

     GETNAMES=YES;

RUN;

Log

 

660 PROC IMPORT OUT= &mth.2013 DATAFILE=

660! "&path\Monthly_Summary_by_LATSK_In_Tran_In_Month_SK_GTET_&mth.2013.xlsx"

661 DBMS=xlsx REPLACE;

ERROR: DBMS type XLSX not valid for import.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE IMPORT used (Total process time):

real time 0.00 seconds

cpu time 0.00 seconds

662 SHEET="BO_Query";

663 GETNAMES=YES;

664 RUN;

The Excel data is stored in a xlsx document with around 190000 records and 4 columns.

I have a similar datastep that is able to read in a different xlsx document. I am not sure what the difference is between them. Any suggestions on resolving this error will be appreciated.

Thanks,
saspert

2 REPLIES 2
ChrisSelley
Calcite | Level 5

Try changing your set statement as below:

%let mth=JUL;

libname  myxls1 "&path\Monthly_Summary_by_LATSK_In_Tran_In_Month_SK_GTET_&mth.2013.xlsx";

data &mth.2013;

    set myxls1."BO_Query$"n;

run;

libname myxls1 clear;

saspert
Pyrite | Level 9

Thanks Chris. I think set myxls1."BO_Query$"n; statement makes a bit of difference. I noticed that Excel add a $ sign to the sheet name while importing - no idea why though.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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