title: Get out the value of a variable in each observation to a macro variable
body: <p>I have a table called <code>term_table</code> containing the below columns</p>
  
  <p><code>comp</code>, <code>term_type</code>, <code>term</code>, <code>score</code>, <code>rank</code></p>
  
  <p>I go through every observation and at each obs, I want to store the value of variable rank to a macro variable called <code>curr_r</code>. The code I created below does not work</p>
  
  <pre><code>Data Work.term_table;
   input  Comp $
          Term_type $
          Term $
          Score
          Rank
        ;
   datalines;
   comp1 term_type1 A 1 1  
   comp2 term_type2 A 2 10
   comp3 term_type3 A 3 20
   comp4 term_type4 B 4 20
   comp5 term_type5 B 5 40
   comp6 term_type6 B 6 100
   ;
  Run;
  
      %local j;
      DATA tmp;
      SET term_table;
      LENGTH freq 8;
  
      BY &amp;by_var term_type term;
      RETAIN freq;
  
      CALL SYMPUT('curr_r', rank);
      IF first.term THEN DO;
          %do j = 1 %to &amp;curr_r;
                           do some thing
                      %end;
      END;
  RUN;
  </code></pre>
  
  <p>Could you help me to solve the problem</p>
  
  <p>Thanks a lot</p>
  
  <p>Hung</p>