title: use field value as a variable in sas
body: <p>Wonder if you can help me</p>
  
  <p>I’ve got a dataset where the value in a column is also the field name of a column. I want to be able to use the value of the column to call the applicable field in a formula.</p>
  
  <p>For instance … I have columns…</p>
  
  <pre><code>MERCH_NO
  V01
  M02
  V08
  M08
  AMOUNT
  PLAN
  </code></pre>
  
  <p>A record would look like this …and what I want the calc field to do…</p>
  
  <pre><code>MERCH_NO      V01   M02  V08  M08  AMOUNT    PLAN    CALC
  123456        2     2    1    1    100.00    V01     value of V01 * AMOUNT
  456789        4     4    4    4    250.00    M08     value of M08 * AMOUNT
  </code></pre>
  
  <p>If the <strong>PLAN</strong> field for a record says <strong>V01</strong>, then the value of the <strong>V01</strong> column must be used in the <strong>CALC</strong> field. If the <strong>PLAN</strong> field says, <strong>M08</strong>, then the <strong>M08</strong> value should be used. There are about 40 plans.</p>