DATA Step, Macro, Functions and more

Reading in an excel file

Reply
Occasional Contributor Doc
Occasional Contributor
Posts: 8

Reading in an excel file

Good morning,

As you know I am new to SAS, but trying to learn.

I just created a new Library with an excel file using the point and click method. I now have a new library called neuneu. It has 3 files in it sheet1$, sheet2$, and sheet3$. When I double click on sheet1$ is contains the data. However, I cannot reference it in a Program file.

I get the following error. It is obviously looking for a .data file. How do I read this file.

1 proc print data=neuneu.sheet1$;
-
22
-
200
ERROR: File NEHU.sheet1.DATA does not exist.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATA, DOUBLE, HEADING, LABEL, N,
NOOBS, OBS, ROUND, ROWS, SPLIT, STYLE, UNIFORM, WIDTH.
ERROR 200-322: The symbol is not recognized and will be ignored.

Thank you,

Doc
Super Contributor
Super Contributor
Posts: 3,174

Re: Reading in an excel file

Do you have a LIBNAME statement pointing to your "external" Excel file with the appropriate "engine" specified? SAS needs this information in order to access the file.

Recommend SAS support http://support.sas.com/ technical papers on this topic - here is a Google advanced search argument you can use to find some matching documentation based on the posted topic:

libname excel engine read sheet site:sas.com


Scott Barry
SBBWorks, Inc.
Occasional Contributor Doc
Occasional Contributor
Posts: 8

Re: Reading in an excel file

I get really confused when tying to read those tech support pages. But I am trying and will get better.

When I created the library using the point and click I chose the excel engine. Do I have to add something else to my program to access the data?
SAS Super FREQ
Posts: 8,868

Re: Reading in an excel file

Hi:
This Tech Support page is very clear:
http://support.sas.com/kb/24/509.html

They show this example, if you're using the Excel Libname engine:
[pre]

LIBNAME XLS 'C:\Excel Files\scores.xls';

DATA NEW;
SET XLS.'SHEET1$'n;
RUN;
[/pre]

which means that a PROC PRINT for the same sheet would be:

[pre]
proc print data=xls.'sheet1$'n;
title 'reading an excel sheet';
run;
[/pre]

cynthia

ps...if you are using SAS Enterprise Guide, then you might find more EG help by posting in the EG forum.
Occasional Contributor Doc
Occasional Contributor
Posts: 8

Re: Reading in an excel file

Posted in reply to Cynthia_sas
Cynthia,

You are the greatest. I will give this a try and let you know.

Will have to be tomorrow. We breed Chinese crested dogs and the puppies need attention.

I will let you know.

Thank you for monitoring these forums as well as you do!
Ask a Question
Discussion stats
  • 4 replies
  • 188 views
  • 0 likes
  • 3 in conversation