BookmarkSubscribeRSS Feed
Abastaki
Calcite | Level 5

I've created an excel files library running this command 

 

options validvarname=v7;

libname xlstorm xlsx '/folders/myfolders/storm.xlsx';

 

but i can't seem to find the worksheet in the library. so how do i do this so i can access the excel worksheet?

 

Screenshot (2)_LI.jpg

17 REPLIES 17
ed_sas_member
Meteorite | Level 14
Hi @Abastaki
Please look at the Error message in the log (red cross)
It seems that the path of the Excel file is not valid. To get the right one, please right click on the file name in the File and Folder part on the left of your screen, and select Properties. You will then be able to copy-paste the path.
Best,
Abastaki
Calcite | Level 5

There's no error message. And i've tried the path you mentioned before, didn't work either.

ed_sas_member
Meteorite | Level 14

Please post the log

Gordonmolapo
Calcite | Level 5

Hi,

 

I have tried to read the storm's excel workbook from the library I have created, however, I am unable to access the file.

Gordonmolapo
Calcite | Level 5

Gordonmolapo_0-1649169010950.png

Attached is the log message after creating the active library.

Kurt_Bremser
Super User

@Gordonmolapo wrote:

Gordonmolapo_0-1649169010950.png

Attached is the log message after creating the active library.


There is no problem. The library reference was successfully created, now use it.

 

In the future, post your logs by just copy/pasting them into a window opened with this button:

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

The "little running man" right next to it is for posting SAS code (provides coloring similar to the SAS Enhanced Editor).

Gordonmolapo
Calcite | Level 5

Hi Kurt,

 

I am using SAS Enterprise guide 7.1. Even after successfully creating the active library, the excel sheets do not appear in the library that I have created.

Kurt_Bremser
Super User

What are the names of your sheets? If they do not follow the rules for valid SAS names, you will have to use

options validmemname=extend;
Gordonmolapo
Calcite | Level 5

Gordonmolapo_0-1649234695788.png

Sheet names

Gordonmolapo
Calcite | Level 5
I used the code suggested but SAS is only reading the first sheet and not the other sheets.

The solution to my initial problem was regarding the path I was using. I used the network path.
Kurt_Bremser
Super User

Please post the code you used to actually read that first sheet.

If you want to read all your sheets in one procedure, use PROC COPY:

proc copy
  in=xstorms
  out=work
;
run;
Gordonmolapo
Calcite | Level 5
libname xstorms '\\HO125489-T\Users\LebohangM\Documents\EPG194\data';

proc import datafile='\\HO125489-T\Users\LebohangM\Documents\EPG194\data\storm.xlsx' 
dbms=xlsx out=xstorms.storm replace;
run;
Tom
Super User Tom
Super User

@Gordonmolapo wrote:
libname xstorms '\\HO125489-T\Users\LebohangM\Documents\EPG194\data';

proc import datafile='\\HO125489-T\Users\LebohangM\Documents\EPG194\data\storm.xlsx' 
dbms=xlsx out=xstorms.storm replace;
run;

If you do not tell PROC IMPORT which worksheet to import from the workbook it will import the first sheet.

 

Kurt_Bremser
Super User

PROC IMPORT without a sheet name will only import the first sheet. IMPORT creates one dataset, so it has to select one sheet, and if you do not tell it which, it defaults to the first.

If you want to import multiple sheets, your best option is PROC COPY from a libname you defined with LIBNAME XLSX.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 17 replies
  • 2293 views
  • 0 likes
  • 7 in conversation