how to count distinct value over two dimension using SAS
<p>I have a dataset looks like the following. This dataset contains four variable Country name <code>Country</code>, company ID <code>Company</code>, <code>Year</code> and <code>Date</code>. </p>

<pre><code>Country  Company  Year  Date 
-------  -------  ----  ----
A        1        2000     2000/01/02
A        1        2001     2001/01/03
A        1        2001     2001/07/02
A        1        2000     2001/08/03
B        2        2000     2001/08/03
C        3        2000     2001/08/03
</code></pre>

<p>I know how to count number of distinct company in each country. I did it using the following code.</p>

<pre><code>proc sql;
   create table lib.count as
   select country, count(distinct company) as count 
   from lib.data
   group by country;
quit;
</code></pre>

<p>My problem is how to count the number of <code>distinct</code> company-Years in each country. Essentially i want to know how many different company or same company in different year. If there are two observation for the same company in the same year, I want to count it as 1 different value. If same company have two observation in differeny year I want to count it as two different value. I want the output looks like the following (one number per country):</p>

<pre><code>Country  No. firm_year
A        2
B        1
C        1
</code></pre>

<p>Can anyone can teach me how to do it please. </p>