title: Copy a value from a line below in SAS
body: <p>I hope this is not a duplicate question. I've searched the forum and retain function seems to be choice of weapon but it copies down an observation, and I'm trying to do the following; for a given id, copy the second line to the first line for the x value. also first value of x is always 2. </p>
  
  <p>Here's my data;</p>
  
  <pre><code>id    x
  3   2 
  3   1
  3   1
  2   2
  2   1
  2   1
  6   2
  6   0
  6   0
  </code></pre>
  
  <p>and i want it to look like this;</p>
  
  <pre><code>id    x
  3   1 
  3   1
  3   1
  2   1
  2   1
  2   1
  6   0
  6   0
  6   0
  </code></pre>
  
  <p>and here's the starter code;</p>
  
  <pre><code>data have;
  input id x;
  cards;
  3   2 
  3   1
  3   1
  2   2
  2   1
  2   1
  6   2
  6   0
  6   0
  ;
  run;
  </code></pre>