【发布时间】:2015-01-22 12:18:02
【问题描述】:
我正在学习 sas 宏语言,但我遇到了问题 我写了一个宏:
%macro avg_acceleration(mark_type, avg_acceleration, mark_angle);
%if &mark_type='A' %then %sysfunc(abs(&avg_acceleration/%sysfunc(cos(%sysfunc(abs(&mark_angle*( 3.1415926535897/180.0)))))));
%else %if &mark_type='C' %then %sysfunc(abs(&avg_acceleration/%sysfunc(sin(%sysfunc(abs(&mark_angle*( 3.1415926535897/180.0)))))));
%mend avg_acceleration;
然后我想做的是在另一个宏中启动一个宏:
%macro statistiche;
data pippo;
set prova;
a = mark_type;
b= avg_acceleration;
c = mark_angle;
avg_acc=%avg_acceleration(a, b, c);
run;
%mend statistiche;
%statistiche;
但我有这个错误:
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.
不能这样使用宏吗??做我想做的事情的正确方法是什么???谢谢
【问题讨论】:
-
您正在以不应该的方式组合数据步骤和宏语言。宏语言编写代码,然后由数据步骤执行;它不应该执行函数本身。