在 SAS 宏循环中不为空
Is not null in SAS Macro loop
嗨,我仍在为 SAS MACRO 循环而苦苦挣扎:
%Let t1=12Mth;
%Let t2=20;
%Let t3=40;
%Let t4=40;
%Let t5=50;
%Let t6=60;
%macro Clean(time);
data Milk1;
set MilkNew;
%Do I = 1 %to &time.;
/*If MilkE=2, then MilkF should be 0 and MilkA should be 0 and should be 99 and MilkT..Sp should be null*/
if (MilkE=2 and (MilkF&&t&I. ne 0 or MilkA&&t&I. ne 0 or (MilkT&&t&I..Sp is not NULL) ) ) then delete;
%end;
run;
%mend Clean;
%Clean(6)
这段代码的目的是删除错误的条目。错误发生在 "is not null" 的 "is" 上。它显示 Expecting an arithmetic operator。为什么这里不能用"is not Null"?有没有其他方法可以做到这一点?
谢谢!
这与宏语言无关。 is not null
在该上下文中(在主数据步骤中)不是有效的 SAS 语法。仅适用于:
PROC SQL
语法
WHERE
语句
WHERE
数据集选项
和其他一些不常遇到的设置。在基本的 SAS 语法中,这是不合法的。
您可以将其替换为对 missing
函数的引用或缺失值(' '
表示字符,.
表示数字)。
if (MilkE=2 and (MilkF&&t&I. ne 0 or MilkA&&t&I. ne 0 or not missing(MilkT&&t&I..Sp) ) ) then delete;
我会这样写的。
嗨,我仍在为 SAS MACRO 循环而苦苦挣扎:
%Let t1=12Mth;
%Let t2=20;
%Let t3=40;
%Let t4=40;
%Let t5=50;
%Let t6=60;
%macro Clean(time);
data Milk1;
set MilkNew;
%Do I = 1 %to &time.;
/*If MilkE=2, then MilkF should be 0 and MilkA should be 0 and should be 99 and MilkT..Sp should be null*/
if (MilkE=2 and (MilkF&&t&I. ne 0 or MilkA&&t&I. ne 0 or (MilkT&&t&I..Sp is not NULL) ) ) then delete;
%end;
run;
%mend Clean;
%Clean(6)
这段代码的目的是删除错误的条目。错误发生在 "is not null" 的 "is" 上。它显示 Expecting an arithmetic operator。为什么这里不能用"is not Null"?有没有其他方法可以做到这一点?
谢谢!
这与宏语言无关。 is not null
在该上下文中(在主数据步骤中)不是有效的 SAS 语法。仅适用于:
PROC SQL
语法WHERE
语句WHERE
数据集选项
和其他一些不常遇到的设置。在基本的 SAS 语法中,这是不合法的。
您可以将其替换为对 missing
函数的引用或缺失值(' '
表示字符,.
表示数字)。
if (MilkE=2 and (MilkF&&t&I. ne 0 or MilkA&&t&I. ne 0 or not missing(MilkT&&t&I..Sp) ) ) then delete;
我会这样写的。