标题: 帮忙看一下,问题在哪里? [打印本页] 作者: shiyiming 时间: 2008-11-1 15:06 标题: 帮忙看一下,问题在哪里? %macro rate(type,promise,money,yeartime);
%global rate tax_rate;
proc sql;
select rate , tax_rate
into : rate ,:tax_rate
from bank_rate as n
where &promise eq n.promise and &type=n.type;
%let rate=&rate ;
%let tax_rate=&tax_rate;
%current_money(&rate,&tax_rate,&money,&yeartime)
%mend rate;
说明:在rate里面,产生的宏变量rate和tax_rate。我想把它们放到嵌套的宏current_money里面作为参数。
上面程序为何不行,怎么老是报错?作者: shiyiming 时间: 2008-11-2 09:38 标题: Re: 帮忙看一下,问题在哪里? 你提交代码片段本身看不出什么问题,把错误代码贴上来,看看是不是其他地方的错误而导致的呢作者: shiyiming 时间: 2008-11-2 18:44 标题: Re: 帮忙看一下,问题在哪里? proc sql; select rate , tax_rate into : rate ,:tax_rate from bank_rate as n where &promise eq
---- ---- -
180 395 200
76
1 ! n.promise and &type=n.type; %current_money(&rate,&tax_rate,&money,&yeartime)
NOTE: Line generated by the invoked macro "CURRENT_MONEY".
1 interest=&money*&current_rate*&yeartime; gain=interest*(1-&tax_rate); current_money=&money+gain;
-
22
ERROR 180-322: Statement is not valid or it is used out of proper order.
ERROR 395-185: Opening parenthesis for SELECT/WHEN expression is missing.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 76-322: Syntax error, statement will be ignored.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
a numeric constant, a datetime constant, a missing value, INPUT, PUT.
不好意思,错误提示比较多。谢谢各位了。作者: shiyiming 时间: 2008-11-2 22:23 标题: Re: 帮忙看一下,问题在哪里? 多了一个分号。作者: shiyiming 时间: 2008-11-3 14:10 标题: Re: 帮忙看一下,问题在哪里? 调用函数current_money是后面少一个分号,而且后面两个%let也不必要
[code:6u37x4vt]%macro rate(type,promise,money,yeartime);
%global rate tax_rate;
proc sql;
select rate , tax_rate into :rate, :tax_rate
from bank_rate as n
where &promise eq n.promise and &type=n.type;
%current_money(&rate,&tax_rate,&money,&yeartime);
%mend rate;
[/code:6u37x4vt]作者: shiyiming 时间: 2008-11-3 14:22 标题: Re: 帮忙看一下,问题在哪里? [quote="horse1":1x5o9wck]调用函数current_money是后面少一个分号,而且后面两个%let也不必要
[/quote:1x5o9wck]
the semicolon after a macro invocation is not mandatory according to the book, but I found it cannot be omitted sometimes. Do you have a general rule or do you just play defensive by placing a semicolon there all the time?作者: shiyiming 时间: 2008-11-3 15:35 标题: Re: 帮忙看一下,问题在哪里? Yes, I always palce a semicolon there to avoid errors作者: shiyiming 时间: 2008-11-3 23:37 标题: Re: 帮忙看一下,问题在哪里? 感谢上面二位。我终于把我的程序写完了。