Hello!
Basically I need to import multiple excel files and simply stack them. I wrote a Macro to do that, but at the end of the code where it comes to the stack part, multiple error messages appear saying:
ERROR: Variable XX has been defined as both character and numeric.
I tried to modify format in the Macro, but it doesn't work.
Will you please take a look at my code and let me know how I should modify it?
Here's the code:
%LET TOTAL=4;
%LET PATH=H:\test\;
%LET INFILE1=a (1).xlsx;
%LET INFILE2=a (2).xlsx;
%LET INFILE3=a (3).xlsx;
%LET INFILE4=a (4).xlsx;
%MACRO EXCELREAD(I,INFILE);
PROC IMPORT OUT=TEST_&i
DATAFILE="&PATH.&INFILE"
DBMS=EXCEL REPLACE;
GETNAMES=NO;
MIXED=YES;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;
%MEND;
%EXCELREAD(1,&INFILE1);
%EXCELREAD(2,&INFILE2);
%EXCELREAD(3,&INFILE3);
%EXCELREAD(4,&INFILE4);
data pilot_bond;
set test_1
test_2(firstobs=2)
test_3(firstobs=2)
test_4(firstobs=2)
run;
Here's the error message:
3712 data pilot_bond; 3713 set test_1 3714 test_2(firstobs=2) 3715 test_3(firstobs=2) 3716 test_4(firstobs=2) ERROR: Variable F1 has been defined as both character and numeric. ERROR: Variable F2 has been defined as both character and numeric. ERROR: Variable F6 has been defined as both character and numeric. ERROR: Variable F7 has been defined as both character and numeric. ERROR: Variable F6 has been defined as both character and numeric. ERROR: Variable F6 has been defined as both character and numeric. 3730 run;
Any help will be greatly appreciated!
Sugguestions to further simplifying the code is also very welcome.
... View more