BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JSCohen
Calcite | Level 5

Hello,

I am trying to import Excel spreadsheets across platforms. I am using the following code but I get an error that Datarow is not valid. My data starts in row 7 and the column headings are in row6.

 

proc import FILE="\\...My file.xlsx"

out=Myfileout

dbms=excelcs  /*ExcelCS is required else I get "Class not registered" */

replace;

sheet="Dashboard";

datarow=7;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

As the error says, datarows is not supported for Excel. You could try specifying a range to import such as Range="sheetname$a6:z200" but you're not going to get variable names from row 6 and would have to use Proc datasets or similar to assign names you want.

 

Or save the file as CSV and remove the first 5 rows before importing.

 

Proc import expects "clean" data, column headings if any in the first row and then data. If the data is clean, a common issue with Excel, then you have to do more work. Or avoid using Excel files for data interchange if possible.

View solution in original post

2 REPLIES 2
ballardw
Super User

As the error says, datarows is not supported for Excel. You could try specifying a range to import such as Range="sheetname$a6:z200" but you're not going to get variable names from row 6 and would have to use Proc datasets or similar to assign names you want.

 

Or save the file as CSV and remove the first 5 rows before importing.

 

Proc import expects "clean" data, column headings if any in the first row and then data. If the data is clean, a common issue with Excel, then you have to do more work. Or avoid using Excel files for data interchange if possible.

Reeza
Super User

Depending on your SAS version, DBMS=XLSX may also work (SAS 9.3 TS2M3+).

 

As specified you can use a RANGE. 

I thought it would still include the names when you specified the RANGE but you can probably test that.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2178 views
  • 0 likes
  • 3 in conversation