title: SAS Enterprise Guide Count IF
body: <p>I'm looking to be able to perform the equivalent of a count if on a data set similar to the below.  I found something similar <a href="https://stackoverflow.com/questions/27559337/counting-rows-in-multiple-variables-using-sas">here</a>, but I'm not sure how to translate it into Enterprise Guide. I would like to create several new columns that count how many date occurrences there are for each primary key by year, so for example:</p>
  
  <pre><code>PrimKey   Date
  1         5/4/2014
  2         3/1/2013
  1         10/1/2014
  3         9/10/2014
  </code></pre>
  
  <p>To be this:</p>
  
  <pre><code>PrimKey   2014   2013
  1         2      0
  2         0      1
  3         1      0
  </code></pre>
  
  <p>I was hoping to use the advanced expression for calculated fields option in query builder, but if there is another better way I am completely open.
  Here is what I tried (and failed):</p>
  
  <pre><code>CASE  
     WHEN Date(t1.DATE) BETWEEN Date(1/1/2014) and Date(12/31/2014)
     THEN (COUNT(t1.DATE))
  END
  </code></pre>
  
  <p>But that ended up just counting the total date occurrences without regard to my between statement.</p>