0

I wrote code to modify values ​​if the values ​​in the two arrays satisfy a condition. However, in the process, all missing values that did not satisfy the conditions were converted to 0.

I want to know why this happened and have the code to fix it. Here is the code I wrote:

data data2;
set data1;

array array_a a1 a2 a3 a4 a5;
array array_b b1 b2 b3 b4 b5;

do i=1 to dim(array_a);
if array_a[i]=0 & array_b[i]=0 then array_a[i]=.;
end;

drop i;
run;
2
  • 5
    You want to set the i'th value in array_a to . if both the i'th value in array_a and array_b is equal to 0, correct? I don't see how your code would set anyting to zero. But please create a representable example with sample data to recreate your problem. Commented Sep 10 at 6:49
  • 1
    That code will not set anything to zero. It only sets values to missing. How do you know the value is zero? Is it possible you changed the MISSING= option to print '0' instead of '.' for missing values? Commented Sep 10 at 23:19

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.