BookmarkSubscribeRSS Feed
Uma_Devi
Fluorite | Level 6

I used the following procedure to create a library using xlsx engine. there are twenty worksheets in the excel file. But in proc contents I am not able to see why?

 

libname xyz xlsx 'C:\Users\Mallik\Desktop\94basepe\input\SDTM_METADATA.xlsx';
run;
proc contents data =xyz._all_ ;
run;
proc datasets lib=xyz;
quit;

 

Log:

libname xyz xlsxl'C:\Users\Mallik\Desktop\94basepe\input\SDTM_METADATA.xlsx';
NOTE: Libref XYZ was successfully assigned as follows:
Engine: EXCEL
Physical Name: C:\Users\Mallik\Desktop\94basepe\input\SDTM_METADATA.xlsx
19626 run;

 

when I use proc contents or proc datasets I am only able to see the following without the list of the sheets in the workbook. The library when verified by opening also had no files. Why did this happen???

Uma_Devi_0-1684330288955.png

 

6 REPLIES 6
Kurt_Bremser
Super User

Since LIBNAME XLSX can be used to create a spreadsheet file, success of the LIBNAME statement does not mean the file is actually there; if it's not there, it would be created with the first write operation to it.

 

Run this:

libname xyz xlsx 'C:\Users\Mallik\Desktop\94basepe\input\SDTM_METADATA.xlsx';

data xyz.class;
set sashelp.class;
run;

and look at the log.

 

BTW LIBNAME is a global statement, which is executed immediately and needs no RUN.

 

Uma_Devi
Fluorite | Level 6
I had to access an excel workbook with several sheets and see the names of
the sheets. The workbook is supposed to have many sheets. But none were
visible in the proc contents procedure after creating the library with the
name of the xlsx file -- SDTM_metadata.
Mark2010
SAS Employee

@Uma_Devi - Based on some earlier conversations, I think you sometimes use On Demand for Academics. Are you using On Demand for Academics for this code?

 

 

Uma_Devi
Fluorite | Level 6
I used Sas 9.4. And this was during my certification test that I had this
problem. While practicing both on Sas studio and Sas 9.4 at home for the
exam, i had no issues.

Sincerely
Uma
Mark2010
SAS Employee

If using a locally installed version of SAS and accessing local files, then you should be OK. But following up on the point made by @Kurt_Bremser , The LIBNAME statement is going to work even if the argument for the Excel file location is wrong. Here is the example of me running your code on my computer:

Mark2010_0-1684336782254.png

Obviously I don't have your file nor your folder structure, but notice my LIBNAME statement does not produce an error. As expected, nothing is displayed in the PROC CONTENTS. I suggest that there is something wrong (such as a typo or the file doesn't exist) with the 'C:\Users\Mallik\Desktop\94basepe\input\SDTM_METADATA.xlsxargument in your code.

Welcome to the Certification Community

 

This is a knowledge-sharing community for SAS Certified Professionals and anyone who wants to learn more about becoming SAS Certified. Ask questions and get answers fast. Share with others who are interested in certification and who are studying for certifications.To get the most from your community experience, use these getting-started resources:

Community Do's and Don'ts
How to add SAS syntax to your post
How to get fast, helpful answers

 

Why Get SAS Certified.jpg

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
  • 6 replies
  • 1447 views
  • 0 likes
  • 3 in conversation