title: converting EXCEL code to SAS
body: <p>I am fairly new to SAS. 
  I designed an algorithm under excel and I am having a lot of trouble converting it to SAS</p>
  
  <p>In Excel :</p>
  
  <pre><code>A B
  -1 1
  1 .
  1 2
  0 1
  -1 .
  -1 2
  </code></pre>
  
  <p>What it does from A to B is that it counts how many times you find the occurrence A in a row. For example (-1) is only here one time, so 1. Then 1, 1 are following each other so I have . (= not significant) followed by 2 (because you have two 1s).
  And so on so on.
  My working excel code for column B is :
  for the first row :</p>
  
  <pre><code>IF (A1 = A2, NA(), 1)
  </code></pre>
  
  <p>for the rest of column B (row 10 for example):</p>
  
  <pre><code>IF(A10 = A11, NA(), COUNTIF($A$1:A9,"="&amp;NA()) + COUNT ($A$1:A9) + 1 - SUMIF($A$1:A9,"&lt;&gt;#N/A"))
  </code></pre>
  
  <p>The code does work, but I really can't find the equivalent in SAS for COUNTIF, SUMIF, and COUNT....</p>
  
  <p>Here is my code so far</p>
  
  <pre><code>data test;
  input sign;
  cards;
  -1
  1
  1
  0
  -1
  -1
  ;
  run;
  
  *create a lead for the equality IF
  proc expand data=test out=test2;
  convert sign= sign_lead / transformout = (lead 1);
  quit;
  </code></pre>
  
  <p>Thanks for your help !</p>