Reputation: 325
Hi I am still struggling with SAS MACRO loop:
%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)
The purpose of this code is to delete the wrong entries. The error occurs on "is" from "is not null". It shows Expecting an arithmetic operator. Why "is not Null" can't be used here? Is there any alternative way to do this?
Thanks!
Upvotes: 0
Views: 3231
Reputation: 63424
This has nothing to do with the macro language. is not null
is not valid SAS syntax in that context (in the main data step). It is only valid in:
PROC SQL
syntaxWHERE
statementsWHERE
dataset optionand a few other infrequently encountered settings. In basic SAS syntax, it is not legal.
You would replace it with either a reference to the missing
function, or the missing value (' '
for character, .
for numeric).
if (MilkE=2 and (MilkF&&t&I. ne 0 or MilkA&&t&I. ne 0 or not missing(MilkT&&t&I..Sp) ) ) then delete;
That would be how I would write that.
Upvotes: 2