title: Array reference in Stata?
body: <p>I need a Stata code similar to this SAS code:</p>
  
  <pre><code>i=1; 
  do while (i &lt;= 6);
      A=B(C(i));
      i=i+1;
  end;
  </code></pre>
  
  <p>Both B and C are arrays as </p>
  
  <pre><code>B_1, B_2, B_3, B_4, B_5 and B_6
  C_1, C_2, C_3, C_4, C_5 and C_6
  </code></pre>
  
  <p>For example, if <code>i</code> = <code>1</code>, then <code>C(i)</code> = <code>C_1</code>.</p>
  
  <p>For row 3, if <code>C_1</code> = <code>5</code>, then I want to set <code>A</code> to <code>B_5</code>.</p>
  
  <p>my problem is with accessing the array entry <code>B(C(i))</code>.  How can I write this access in Stata?</p>