DATA Step, Macro, Functions and more

proc import

Reply
Occasional Contributor
Posts: 12

proc import

Hi,

 

while running this program.

 

proc import datafile="Z:\Users\Ramanathan\test1.xls" out=ab dbms=excel replace;
sheet="xdm";
getnames=yes;
datarow=4;
run;

 

I'm getting error in datarow statement. I don't know why? can anyone explain me.

 

Thanks

Super User
Posts: 17,824

Re: proc import

Is datarow supported for DBMS Excel? It doesn't look like it.

What version of SAS do you have?

 

It's sometimes hard to navigate the documentation for PROC Import. 

 

http://support.sas.com/documentation/cdl/en/acpcref/67382/HTML/default/viewer.htm#n0msy4hy1so0ren1ac...

Occasional Contributor
Posts: 12

Re: proc import

hi reza,

 

I have sas 9.2.

Occasional Contributor
Posts: 12

Re: proc import

hi,

 

how to read multiple sheet from a excel file with xsl engine. And how to restrict the number of obs in the dataset while importing from an excel file.

Super User
Posts: 17,824

Re: proc import

Try a libname method with proc copy or datasets. 

Assign a libname and then use PROC datasets with a copy statement to copy sheets to library. 

 

How do you want to restrict observations? What's your logic?

Super User
Super User
Posts: 7,401

Re: proc import

What is the question here exactly?  To import from Excel your options are proc import, libname excel, saving the file to a proper formats such as CSV and datastep import - all of which there are thousands of examples on here.  To limit the number of observations, just read the file, then do:

data want;

  set have (obs=...);

run;

 

To read multiple sheets, use the sheetname="..." option in proc import, or save each sheet to a separate CSV, or use libname excel.

 

Super User
Posts: 9,681

Re: proc import

Try
startrow=4

or multiple range option:
range='A1:D10';
range='A10:D20';

Ask a Question
Discussion stats
  • 6 replies
  • 254 views
  • 2 likes
  • 4 in conversation