title: Lag a column using linux
body: <p>How can I lag a column using linux? For example in SAS the below code would work.</p>
  
  <pre><code>lag2=lag(error2);
  lag3=lag2(error2);
  lag4=lag3(error2);
  lag5=lag4(error2); 
  </code></pre>
  
  <p>The input is the following</p>
  
  <pre><code>id1 id2 id3 numb error 
  1 2 1 1_135098 OK  
  0 2 0 1_267940 code3
  0 0 0 1_305793 OK 
  0 2 0 1_393248 code3 
  0 5 1 1_434180 OK 
  0 2 0 1_471078 code3 
  </code></pre>
  
  <p>The output I would like is, where I am lagging the fifth column 4 times</p>
  
  <pre><code>id1 id2 id3 numb error lag2 lag3 lag4 lag5
  1 2 1 1_135098 OK . . . . 
  0 2 0 1_267940 code3 OK . . .
  0 0 0 1_305793 OK code3 ok . .
  0 2 0 1_393248 code3 ok code3 ok .
  0 5 1 1_434180 OK code3 ok code3 ok
  0 2 0 1_471078 code3 ok code3 ok code3
  </code></pre>