BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Kumar6
Obsidian | Level 7

Hi All, 

 

I am trying to get the data from an excel sheet into the sas dataset. I need the data in excel sheet starting from row 6 and row 5 should be a column names. When I tried to get this with below code its giving me an error( Statement is not valid or it is used out of proper order) for the last 4 statements(mixed,  namerow, startrow, endrow). Can anyone please suggest me any other alternate way on this.

 

proc import datafile = "C:\CR-6365.xlsx"
DBMS = xlsx
OUT = a1
REPLACE;;
sheet = "PQCs For CRAs";
GETNAMES =Yes;
Mixed=YES;
namerow=5;
startrow=6;
endrow=16;
quit;

 

Thanks,

Kumar.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Maxim 1: Read the Documentation.

In this case, the specific page for Microsoft Workbook Files 

There are no NAMEROW, STARTROW or ENDROW statements for DBMS=XLSX (only for DBMS=XLS).

Instead, use a RANGE= statement to direct SAS to the correct part of the spreadsheet. The specific part for the RANGE statement is here.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

Maxim 1: Read the Documentation.

In this case, the specific page for Microsoft Workbook Files 

There are no NAMEROW, STARTROW or ENDROW statements for DBMS=XLSX (only for DBMS=XLS).

Instead, use a RANGE= statement to direct SAS to the correct part of the spreadsheet. The specific part for the RANGE statement is here.

Tom
Super User Tom
Super User

Sounds like you have the same issue as this other question.

Just tell it where to start.  

proc import
   datafile = "C:\CR-6365.xlsx"
  DBMS = xlsx
  OUT = a1 REPLACE
;
  range =  "PQCs For CRAs$A5:";
run;
Kumar6
Obsidian | Level 7
It worked. Thank You.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 500 views
  • 2 likes
  • 3 in conversation