Desktop productivity for business analysts and programmers

Reading Spreadsheet data

Reply
New Contributor
Posts: 2

Reading Spreadsheet data

[ Edited ]

 

How to I resolve the error below?

 

NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
21
22 GOPTIONS ACCESSIBLE;
23 options validvarname=v7;
24 %let path=\\dpc4-75617d\C$\Users\MathapeloPh\Desktop\Move_9093777\Listing Files\Output_Files_Sent_to_Field;
25
26 libname fieldx xlsx "\\%path\PSUs_Segments_161116.xls";
WARNING: Apparent invocation of macro PATH not resolved.
NOTE: Libref FIELDX was successfully assigned as follows:
Engine: XLSX
Physical Name: \\%path\PSUs_Segments_161116.xls
27
28
29 proc contents data=fieldx._ALL_;
30 run;

WARNING: No matching members in directory.
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.03 seconds
cpu time 0.04 seconds

Super User
Posts: 7,443

Re: Reading Spreadsheet data

A macro variable needs to be adressed as &name. %name would call a macro.

Try

libname fieldx xlsx "\\&path.\PSUs_Segments_161116.xls";

Also note the dot after the macro variable; this makes sure that the macro processor stops scanning for further characters when building the macro variable name.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 2

Re: Reading Spreadsheet data

Thanks @KurtBremser the libname was successfully assigned. Kindly check the warning below it as I now try to read sheets inside the file:

 

libname fieldx xlsx "\\&path.\PSUs_Segments_161116.xls";
NOTE: Libref FIELDX was successfully assigned as follows:
Engine: XLSX
Physical Name: \\\\dpc4-75617d\C$\Users\MathapeloPh\Desktop\Move_9093777\Listing
Files\Output_Files_Sent_to_Field\PSUs_Segments_161116.xls
27
28
29 proc contents data=fieldx._ALL_;
30 run;

WARNING: No matching members in directory.

Super User
Posts: 7,443

Re: Reading Spreadsheet data

I guess that happens because proc contents (or the contents statement in the datasets procedure) are meant for SAS datasets.

Try this instead:

proc datasets library=fieldx;
quit;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 3 replies
  • 258 views
  • 0 likes
  • 2 in conversation