title: Rename Variable Regardless of its Name in SAS
body: <p>Lets suppose we have the following dataset:</p>
  
  <pre><code>ID    Stress_Level    Heart_Rate
  1          5              10
  2          7              12
  3          9              16
  </code></pre>
  
  <p>And the code one would use to rename a variable would be:</p>
  
  <pre><code>data test1;
      set test0;
      rename Stress_Level=A Heart_Rate=B;
  run;
  </code></pre>
  
  <p>However, what I would like to do is to rename the 2 columns without using their names. Is there an "internal" SAS command that addresses the variable depending on which column it is? So for instance Stress_Level which is the 2nd column could be addressed as "COL2 " or something similar. Thus the code would be:</p>
  
  <pre><code>data test1;
      set test0;
      rename COL2=A COL3=B;
  run;
  </code></pre>
  
  <p>Where "COL2" would always refer to the second column in the dataset regardless of its name. Is there a direct or maybe an indirect way to achieve that?</p>