title: Sum monthly into yearly in SAS
body: <p>I have the following data set:</p>
  
  <pre><code>  Date        Occupation      Count
  Jan2006        Nurse            15
  Jan2006        Lawyer           2
  Jan2006        Mechanic         3
  Feb2006        Economist        2
  Feb2006        Lawyer           1
  Feb2006        Nurse            5
  </code></pre>
  
  <p>The data continues all the way until Dec 2014 with difference occupations and and counts for each occupation. What I want to do is to create an aggregate the counts by occupation all into one year. So assuming that the above data has all the months and counts I want my final data set to look like this:</p>
  
  <pre><code>Date     Occupation    Sum
  2006      Nurse         20
  2006      Lawyer        3
  2006      Mechanic      3
  2006      Economist     2
  and so on until Dec2014. 
  </code></pre>
  
  <p>I tried using the first.variable and last.variable as follows but it didn't work. </p>
  
  <pre><code>data want,
     set have;
  if first.date and first.Occupation then sum = 0;
  sum+Count;
  if last.date and last.occupation then output; 
  run;
  </code></pre>
  
  <p>But this doesn't give me the desired output. I feel like this could be done easily in SQL, but not being familiar with SQL, I am hesitant to use it. </p>
  
  <p>Thanks in advance for your help. </p>