title: How to modify the array value based on another variable in SAS?
body: <pre><code>data tempx1;
    input ID;
    cards;
    1
    2
    3
    4
    ;
  run;
  
  data tempx2;
     set tempx1;
     array diag{4} d1 d2 d3 d4 (1,2,3,4);
       do i = 1 to 4;
        if diag[i] = ID then diag[i] = 1; else diag[i] = 0;
       end;
      drop i;
  run;
  </code></pre>
  
  <p>I want 1's to be in the diagonal of the array, what did i do wrong here?</p>