Reputation: 315
Why doesn't the following code return the only row available in my data lines statement?
data lines;
input a $ b $ c $ d $ e $ f $;
datalines;
word yes no maybe so blah
;
run;
data tst;
set lines;
array memo{6} a b c d e f;
do i = 1 to dim(memo);
if find(memo{i},"y","i");
end;
run;
There should be hits on variables b
and d
based on the character variable y
Upvotes: 0
Views: 574
Reputation: 9569
Recall that if condition;
is equivalent to if not condition then delete;
. As soon as SAS hits the first non-matching word, it executes the delete statement and stops processing the current observation. Try if condition then output;
instead.
Now you'll get two rows in the resulting output dataset. If you only want at most 1 row, then consider setting a flag variable, e.g.
data tst;
set lines;
array memo{6} a b c d e f;
flag = 0;
do i = 1 to dim(memo);
if find(memo{i},"y","i") then flag = 1;
end;
if flag;
run;
Upvotes: 2