BookmarkSubscribeRSS Feed
tianerhu
Pyrite | Level 9
libname apple  'C:\Users\Documents\Sales.xls';
proc print  data = apple.Sales;
   where EmpID = '9888' or EmpID = '0177';

run;


23 REPLIES 23
Kurt_Bremser
Super User

@tianerhu wrote:
libname apple  'C:\Users\Documents\Sales.xls';
proc print  data = apple.Sales;
   where EmpID = '9888' or EmpID = '0177';

run;



And what is your problem? If you get ERRORs or WARNINGs, post the log. Otherwise describe what does not work as intended.

tianerhu
Pyrite | Level 9

thank you for your advice, sir , following is the information from log

2023
2024 libname apple 'C:\Users\Documents\Sales.xls';
ERROR: Connect: Class not registered
ERROR: Error in the LIBNAME statement.
2025
2026 proc print data = apple.Sales;
ERROR: Libref APPLE is not assigned.
2027 where EmpID = '9888' or EmpID = '0177';
WARNING: No data sets qualify for WHERE processing.
2028
2029 run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds

 

SASKiwi
PROC Star

Try adding the an engine to your LIBNAME:

libname apple XLS 'C:\Users\Documents\Sales.xls';

Your spreadsheet need to to contain a tab called Sales as well.

tianerhu
Pyrite | Level 9

thank you  , but it still does not work

tianerhu
Pyrite | Level 9

 spreadsheet need to to contain a tab called Sales as well.

 

what does that mean ?

 

yes ,the file " Sales.xls"  in the C:\Users\Documents\Sales.xls'  , it was there , and in the spreadsheet , just only one worksheet

Reeza
Super User
When programming you have to first ensure that the prior code works. So currently you're trying to set up a libname to an Excel file. It appears that doesn't work. What errors do you get, post your full log from your LIBNAME statement.

Either you don't have the correct license, your code is wrong, or you need PCFILES because you have a mismatch between 32bit and 64 bit system.

Once the libname to the Excel file is set up, you can reference the different tables in the workbook but you need to know the names. PROC DATASETS is a good way to explore that to find out what names you need to use. Generally, you can use the worksheet names in the Excel workbook as data set names, but named ranges can also be a data set name and possibly Excel Tables as well these days. Also, do you have to work with an xls file or can it be an XLSX file? If you can use XLSX you have more modern options, XLS was retired about a decade ago.
tianerhu
Pyrite | Level 9

thank you for your help , following is the information from log :

yes , my SAS is 64 byte, and the xls file is 32 byte , but i have install PC file server.

by the way , what's the name range?

2121
2122 libname apple XLS 'C:\Users\Documents\Sales.xls';
ERROR: The XLS engine cannot be found.
ERROR: Error in the LIBNAME statement.
2123
2124 proc print data = apple.Sales;
ERROR: Libref APPLE is not assigned.
2125 where EmpID = '9888' or EmpID = '0177';
WARNING: No data sets qualify for WHERE processing.
2126
2127 run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.20 seconds
cpu time 0.00 seconds

 

Tom
Super User Tom
Super User

Did you try using the PCFILES engine? 

Have you ever gotten the PC Files Server to work?

tianerhu
Pyrite | Level 9

thank you for your help .

yes , i try PCFILES,but it still doesn't work

i have installed the  PC files server, when i use wizard import to invert the xls files to csv files , it works well

Reeza
Super User

Named ranges are an Excel concept, they allow you to create a reference to a table without having a specific sheet. 

What about the following:

 

libname apple pcfiles path= 'C:\Users\Documents\Sales.xls';

proc datasets lib=apple; run;

@tianerhu wrote:

thank you for your help , following is the information from log :

yes , my SAS is 64 byte, and the xls file is 32 byte , but i have install PC file server.

by the way , what's the name range?

2121
2122 libname apple XLS 'C:\Users\Documents\Sales.xls';
ERROR: The XLS engine cannot be found.
ERROR: Error in the LIBNAME statement.
2123
2124 proc print data = apple.Sales;
ERROR: Libref APPLE is not assigned.
2125 where EmpID = '9888' or EmpID = '0177';
WARNING: No data sets qualify for WHERE processing.
2126
2127 run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.20 seconds
cpu time 0.00 seconds

 


 

tianerhu
Pyrite | Level 9

it works , but that is not what i want .

 

 

 

SASKiwi
PROC Star

If the PCFILES engine works, please post your PROC DATASETS log. Does it list the worksheets in your Excel workbook?

SASKiwi
PROC Star

Trying to print a table called Apple.Sales that is in an Excel workbook called Sales means you are referencing a worksheet within the workbook called Sales also. If your worksheet is not called Sales then your program will fail with an error - dataset not found.  

tianerhu
Pyrite | Level 9

thank you , but , it still doesn't work

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 23 replies
  • 1754 views
  • 2 likes
  • 5 in conversation