写了一段宏,怎么都测试不出结果。数据格式如下,计算过程是:1。先判断
count12是否有数,有的话,取其具體数的绝对值,即是其对应的月份的IOP进行相减。如:count21=15,其前面count11=9,则IOP_15m-IOP_9m.中間鑲嵌了一段判斷具體是哪一類相減,一共6種,包括(IOP_B_B IOP_PGA IOP_Miotic IOP_CAI IOP_Diamox IOP_Adren).
每次程序都報錯說:ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: count21
我檢查過了,count21都是數值型,所以不是這個的問題,懷疑是數據讀取的問題,但是自己怎麼也發現不了。還望有高手來救我。
count11 | count21 | count31 | IOP_3m | IOP_6m | IOP_9m | IOP_12m | IOP_15m | IOP_18m |
9 | 15 | 18 | 15 | 16 | 21 | 18 | 19 | 20 |
| | | 17 | 17 | 18 | 19 | 15 | 16 |
-12 | 15 | 18 | 16 | 21 | 18 | 15 | 16 | 21 |
3 | 6 | | 17 | 18 | 19 | 17 | 17 | 18 |
%macro IOP12(i=);
%let x=%eval(count&i.1);
%let j=%eval(&i-1);
%let b=%eval(count&j.1);
data IOP1_begin3m;
set IOP1_begin3m;
if abs(coun&i.1)>0 then do;
if B_B_&x.M_c ~= B_B_&b.M_c then IOP_B_B=IOP_&x.M-IOP_&b.M;
else if PGA_&x.M_c ~= PGA_&b.M_c then IOP_PGA=IOP_&x.M-IOP_&b.M;
else if Miotic_&x.M_c ~= Miotic_&b.M_c then IOP_Miotic=IOP_&x.M-IOP_&b.M;
else if CAI_&x.M_c ~= CAI_&b.M_c then IOP_CAI=IOP_&x.M-IOP_&b.M;
else if Diamox_&x.M_c ~= Diamox_&b.M_c then IOP_Diamox=IOP_&x.M-IOP_&b.M;
else if Adren_&x.M_c ~= Adren_&b.M_c then IOP_Adren=IOP_&x.M-IOP_&b.M;
end;
run;
%mend IOP12;
%IOP12(i=2);