全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
4327 16
2012-02-13
写了一段宏程序,怎么调试都得不到结果,很头大,求助各位大虾。程序如下,当N=1时,sum_drugs_&y.M_sum_drugs_&x.M就变成sum_drugs_6M_sum_drugs_3M,这个变量数据库自带并且是数值型。但是每次运行的时候,就说 A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:      sum_drugs_6M_sum_drugs_3M。也就是说sum_drugs_6M_sum_drugs_3M不是数值型!!不知道怎么回事啊~~

%macro drugpoint(N=);
%do i=&N %to 7;
    %let x=%eval(&N*3);
    %let y=%eval((&N+1)*3);
    %let drugs_ab=%eval(sum_drugs_&y.M_sum_drugs_&x.M);
   %if &drugs_ab=1 or &drugs_ab=-1  %then %do;
    %if B_B_&x.M_c ~= B_B_&y.M_c %then IOP_B_B=IOP_&y.M-IOP_&x.M;
%else %if  PGA_&x.M_c ~= PGA_&y.M_c %then IOP_PGA=IOP_&y.M-IOP_&x.M;
%else %if  Miotic_&x.M_c ~= Miotic_&y.M_c %then IOP_Miotic=IOP_&y.M-IOP_&x.M;
%else %if  CAI_&x.M_c ~= CAI_&y.M_c %then IOP_CAI=IOP_&y.M-IOP_&x.M;
%else %if  Diamox_&x.M_c ~= Diamox_&y.M_c %then IOP_Diamox=IOP_&y.M-IOP_&x.M;
%else %if  Adren_&x.M_c ~= Adren_&y.M_c %then IOP_Adren=IOP_&y.M-IOP_&x.M;
   %end;
%end;
%mend  drugpoint;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-2-13 17:51:05
问题在于drugs_ab是神马……你在%let drugs_ab之后写一行%put &drugs_ab看看~~
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-2-13 18:03:19
zhangzachary 发表于 2012-2-13 17:51
问题在于drugs_ab是神马……你在%let drugs_ab之后写一行%put &drugs_ab看看~~
多谢提醒!试过了,不行,还是同样的系统错误 A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: sum_drugs_6M_sum_drugs_3M。根据sas系统提醒,貌似是认错变量类型啊~~
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-2-13 18:15:56
andrea1983 发表于 2012-2-13 18:03
多谢提醒!试过了,不行,还是同样的系统错误 A character operand was found in the %EVAL function or  ...
查看%eval 的用法
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-2-13 22:22:48
sum_drugs_&y.M_sum_drugs_&x.M是数据表中的一个变量,不能直接复制给宏变量,可以通过sql语句或data步将其值赋给宏变量drugs_ab
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-2-13 23:57:03
有可能是你宏变量的赋值有问题。你试一下 %let drugs_ab=&&sum_drugs_&y.M_sum_drugs_&x.M;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群