0
基本上我需要導入多個excel文件並簡單地堆疊它們。我寫了一個宏來做到這一點,但是在代碼到達堆棧部分的末尾,出現了多條錯誤消息: 錯誤:變量XX已被定義爲字符和數字。 我試圖修改宏中的格式,但它不起作用。 (我試過「format F1 = DDMMYY10,F2 = 12.8,F7 = $ 12」) 我也只需要保留F1-F7。但是日誌說「在此版本的SAS系統的過程步驟中不支持DROP和KEEP語句」。因此,這些陳述被忽略。SAS「錯誤:變量已被定義爲字符和數字」
請你看看我的代碼,讓我知道我該如何修改它? 下面的代碼:
%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;
/*KEEP F1 F2 F3 F4 F5 F6;
FORMAT F1=DDMMYY10, F2=12.8, F7=$12;*/
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;
這裏的錯誤消息:
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;
任何幫助將不勝感激! 建議進一步簡化代碼也非常受歡迎。