Retrieving data from an Excel worksheet with a long name - SAS

I am trying to read a value from an Excel file using SAS. This file is default and will be downloaded every day, so I would prefer not to change the daily sheet name.

The problem currently is that if more than one sheet is fetched on one day (this is done in the month and mid-month files) my code does not work as it expects the sheet name to be specified. The problem with the system-generated name Sheet is that it is too long for SAS.

Here is my current code (note that if the file contains only one sheet, I can delete the Sheet Title section and then this code works fine):

libname xl Excel "&full_file_route" header=no access=readonly; 

proc sql NOPRINT;
    select F1 as file_indicator 
    into :file_indicator
    from xl.'Accounts Per Country Incl. Developing$A3:A3'n;
quit;

      

How can I get data from this source without changing the sheet name?

UPDATE:

I have also tried using PROC IMPORT with the same result:

PROC IMPORT OUT= test DATAFILE= "\\<filename...>.xls" 
    DBMS=EXCEL REPLACE;
    SHEET='Accounts Per Country Incl. Developing';
    RANGE='A3:A3';
RUN;

      

The result says:

ERROR 65-58: Name 'Accounts Per Country Incl. Developing$A3:A3' is too long for a SAS name in this context.

      

+3


source to share





All Articles