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

The  file which i am trying to import contains variable names at row 3 and data begins at row 4

following is the code I have done 

 

PROC IMPORT OUT = NEW
DATAFILE= "\\temp.xlsx"
DBMS=XLSX REPLACE ;
NAMEROW=3;
DATAROW=4;
GETNAMES=YES;
RUN;

 

I am getting error that Namerow is not used properly.

1 ACCEPTED SOLUTION
7 REPLIES 7
ChrisNZ
Tourmaline | Level 20

It's all in the documentation!

 

See section "Available Statements for Importing and Exporting Excel Files Using DBMS=XLS and DBMS=XLSX"

at http://documentation.sas.com/?docsetId=acpcref&docsetTarget=n0msy4hy1so0ren1acm90iijxn8j.htm&docsetV...

 

NAMEROW is not available for DBMS=XLSX, use RANGE instead.

sas_learnsups
Obsidian | Level 7

@ChrisNZ: I did go through the documentation you attached above but somehow range option didn't work for me. 

I saved the copy of file in CSV format and then could import it in SAS dataset. 

 

Thank you very much. Your documentation is of much help to me.

 

 

 

Patrick
Opal | Level 21

@sas_learnsups wrote:

Thanks anyways

 


I believe you've missed that @ChrisNZ has given you the full solution and even has taken the time to look-up and post the link to the relevant documentation for you. You need to use RANGE instead of NAMEROW and things will work. ...and the syntax for RANGE is fully documented in the posted link.

 

If you want us to fix your code and post something working and tested then you need to provide the sample data to do so.

sas_learnsups
Obsidian | Level 7

@Patrick- I did go through the documentation provided by "ChrisNZ".

 

I will keep in mind to attach a screenshot or sample data, next time I post a quesion in SAS communities.

 

Many Thanks,

sas_learsups

ballardw
Super User

@sas_learnsups wrote:

@ChrisNZ: I did go through the documentation you attached above but somehow range option didn't work for me. 

I saved the copy of file in CSV format and then could import it in SAS dataset. 

 

Thank you very much. Your documentation is of much help to me.

 

 

 


Did't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Save the XLSX file as CSV.  Have a datastep:

data _null_;
  file "abc.csv";
  infile "abc.csv";
  input;
  if _infile_ ne "title1" and _infile_ ne "title2" then put _infile_;
run;

Drops the two title rows assuming they have the text title1/2.  You can then write a datastep to read in that csv correctly, per your data specifications documentation.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 5002 views
  • 3 likes
  • 5 in conversation