title: SAS if first.variable then do assign value
body: <p>I have a dataset that is sorted by 6 variables.</p>
  
  <p>I want to use the first.variable ( in my case the sixth variable) to set initial values for a new variables (7th,8th variables) of the data set.</p>
  
  <p>Example: </p>
  
  <pre><code>if first.variable_name then do;
  ratevalue = 999;
  factor = 100.00;
  end;
  </code></pre>
  
  <p>the first.variable is the 6th variable in the groupby.</p>
  
  <p>The first column in the group has a date value of '3-20-2017' hardcoded. So there is only 1 group with the fist column comprising of all 200K observations.</p>
  
  <p>Question is when I execute the above piece of code I am expecting the ratevalue and factor assigned to the observations where first.variable_name  = '1'.</p>
  
  <p>However, the the values are assigned to all the 200k observation starting with the first.variable.</p>
  
  <p>If i use </p>
  
  <pre><code>if last.variable_name then do;
  
  'ratevalue = 999;'
  factor = 100.00;
  end;
  </code></pre>
  
  <p>then it is assigning the above values to all the observations starting from the last observation of the group made by the 6th variable in the group.</p>
  
  <p>Is that how it is supposed to work.</p>
  
  <p>Thanks!</p>