Help using Base SAS procedures

Programming 1: Essentials Lesson 7 Question

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Programming 1: Essentials Lesson 7 Question

Hello, I'm getting this error

ERROR: The PCFILES engine cannot be found.

ERROR: Error in the LIBNAME statement.

I'm trying to run this code:

libname custfm pcfiles path="&path/custfm.xls";

proc contents data=custfm._all_;

run;

data work.males;

run;

proc print data=work.males label;

run;

libname custfm clear;

Any thoughts as to what is wrong?


Accepted Solutions
Solution
‎12-30-2014 03:57 PM
Frequent Contributor
Posts: 115

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

did the libname get successfully assigned?

if yes, do a test using

proc contents data=custfm._all_;/* this will list you the datasets in the excel that you are reading */

run; 

If there aint any, well, you would have to know where your xls file is placed, i mean the exact location, find that, get it's path and replace exactly in the syntax and do again.

Alternatively, import the xls file to your SAS environment using the import wizard or proc import and get started with your SAS stuff. If this fails too, store the file as csv file and read with infile and input statements. Have fun!!!

View solution in original post


All Replies
Frequent Contributor
Posts: 115

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

I don't think you need to specify pcfiles engine and path= coz &path will just resolve to the defined path of macro by the macro processor by substituting it's value from the global symbol table and places it back into the input stack.

libname custfm "&path\custfm.xls"; *this should work getting your libname assigned.

Super User
Posts: 19,869

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

Are you in SAS University Edition?

Occasional Contributor
Posts: 8

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

No, I'm not in the SAS University Edition.

Super User
Posts: 19,869

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

Is PCFILES Server installed?

Do you need to use PCFILES at all?  It's used when you have SAS 64 bit and Excel 32 Bit.

What version of SAS do you have and what bitness? Also what version of Excel and bitness?

Occasional Contributor
Posts: 8

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard


Naveen, I got this error when running what you advised:

 

WARNING: Apparent symbolic reference PATH not resolved.

ERROR: Connect: 'C:\Users\cflach\Documents\&path\custfm.xls' is not a valid path. Make sure

that the path name is spelled correctly and that you are connected to the server on

which the file resides.

ERROR: Error in the LIBNAME statement.

Frequent Contributor
Posts: 115

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

Hi, &path will hold the value of the path. So if you are specifying the full path name, don't use macro &path

libname libref "your path"; *this is the syntax;

try this:  libname custfm 'C:\Users\cflach\Documents\custfm.xls' ; * assuming this is where your xls file is located;

Occasional Contributor
Posts: 8

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

Reeza,

How do I know if PCFILES server is installed?

Where do I find the bitness for SAS and Excel?

Thanks!!

Super User
Posts: 19,869

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

I would first try suggestion of hard coding the path, except with the EXCEL specified. Remember for macro variables to resolve you need to use double not single quotes.

libname custfm excel 'C:\Users\cflach\Documents\custfm.xls' ;


For PC File Server if you're on Windows desktop go to Programs>SAS>PC FILE SERVER should be in the list of applications.


For bitness of SAS, in SAS go to HELP>About SAS and see what is under Software Information.




Super User
Posts: 11,343

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

When referencing a macro variable and other literal text you need a . after the macro variable to indicate the end of the variable and that the remainder text is appended. &path/custfm.xls is going to look for a macro variable with /custfm as part of the name, which isn't a legal name and won't exist. Use &path./custfm.xls or &path.\custfm.xls depending on Operating System.

Occasional Contributor
Posts: 8

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

Thank you, Naveen.

I think I'm getting closer. I did get this warning though with nothing in the output:

 

WARNING: No matching members in directory.

Solution
‎12-30-2014 03:57 PM
Frequent Contributor
Posts: 115

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

did the libname get successfully assigned?

if yes, do a test using

proc contents data=custfm._all_;/* this will list you the datasets in the excel that you are reading */

run; 

If there aint any, well, you would have to know where your xls file is placed, i mean the exact location, find that, get it's path and replace exactly in the syntax and do again.

Alternatively, import the xls file to your SAS environment using the import wizard or proc import and get started with your SAS stuff. If this fails too, store the file as csv file and read with infile and input statements. Have fun!!!

Occasional Contributor
Posts: 8

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

I think that worked. Sorry, I'm super new to SAS. Thank you so much!!

Super User
Posts: 19,869

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

Please mark question answered, I believe it goes

Occasional Contributor
Posts: 8

Re: Programming 1: Essentials Lesson 7 Question

Posted in reply to flachboard

I'm sorry, this is my first time. How do I mark a question answered?

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 15 replies
  • 658 views
  • 3 likes
  • 4 in conversation