Question

I try to use datarow oprion

proc import 
datafile = "C:....\Book1.xlsx"
out=test
dbms=excel replace
;
RANGE="'test$'"; 
datarow=2;          /* this line throws an error Statement is not valid or it is used out of proper order */

getnames=no ;
run;

When i use the above code without datarow the file gets imported fine . How can i start importing form second line ? I also tried startrow ( I have sas 9.2 )

Was it helpful?

Solution 2

If you are using a custom range, as you are in that code, you cannot prevent it from taking the first row (unless they're used by names, but you reject that). You need to re-create the range to not include the first row.

If they don't harm the import (ie, they don't cause the data types to change), you could always eliminate the first row via subsetting the dataset (how depends on the circumstances of the data).

OTHER TIPS

When you use getnames=no the default behaviour is to read from line 1. That's why you're getting your error.

Try setting getnames=yes which reads from line 2 by default.

Below is what worked for me; the data can be either xlsx or xlsm (at least that is what i tested):

PROC IMPORT OUT=Out_Table
    DATAFILE=Import_File
    DBMS=EXCEL REPLACE;
    SHEET="Sheetname$";
    RANGE="A2:S";
    GETNAMES=YES;
    MIXED=YES;
run;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top