Я пытался выполнить код sas с использованием массивов.Странно, это не работает так, как я ожидал.Поэтому я использовал другой подход, и код работает нормально со вторым методом.Но все же я хочу знать, что это не так с первым методом.Вот мой код:
data have;
input free_m prevention substitution oth;
datalines;
. . . .
. 0 0 0
1 1 0 0
;
run;
data test;
set have;
/*method1*/
array a1(*) prevention substitution oth;
do i=1 to dim(a1);
if free_m=. and prevention=0 and substitution=0 and oth=0 then a1(i)=.;
end;
/*method2*/
/*
if free_m=. and prevention=0 and substitution=0 and oth=0 then
do;
prevention=.;
substitution=.;
oth=.;
end;
*/
drop i;
run;
proc sql;
select * from test;
quit;
Результат с / method2 / правильный, и это то, что я хочу:
![enter image description here](https://i.stack.imgur.com/qoi1X.png)
Но с / method1 / я получаю следующий вывод:
![enter image description here](https://i.stack.imgur.com/Dd7S7.png)
Что-то не так вmethod1?Пожалуйста, помогите!Большое спасибо.