2014-09-30 107 views
0

爲什麼這很容易宏程序:SAS簡單的宏 - 錯誤

%macro test1(N=,NN=); 
proc iml; 
start fun_test(x) global(&NN,&N); 
x=&NN+&N; 
finish fun_test; 
call fun_test(x); 
print x; 
run; 
quit; 
%mend test1; 
%test1(N=10,NN=22); 

給出了錯誤? :

 22 
ERROR 22-322: Expecting a name. 
ERROR 200-322: The symbol is not recognized and will be ignored. 
+0

實際上,它給出正確的答案,但這個錯誤仍然 – Math 2014-09-30 11:33:45

+0

難道不應該更喜歡:'%宏test1的(N,NN); proc iml; 開始fun_test(x)的全球(NN,&N); X = &NN+&N; 光潔度fun_test; 呼叫fun_test(X); 打印X; 運行; 退出; %補TEST1; %TEST1(10,22); ' – jaymarvels 2014-09-30 11:35:22

+0

謝謝@ jj72uk但我仍然有同樣的錯誤 – Math 2014-09-30 11:44:07

回答

1

START語句的GLOBAL子句需要有效SAS標識符的名稱。當您調用宏時,程序解析爲

start fun_test(x) global(22,11); 
    ... 

這是無效的語法。

也許這就是你要找的?

%macro test1(N=,NN=); 
proc iml; 
start fun_test(x) global(N,NN); 
x=N + NN; 
finish fun_test; 
N = &N; NN = &NN; 
call fun_test(x); 
print x; 
run; 
quit; 
%mend test1; 
%test1(N=10,NN=22);