<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Count while skipping duplicates in proc freq in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72652#M15653</link>
    <description>PROC FREQ will give you those count using the LEVELS proc statement option.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
   input ID DATE:mmddyy.;&lt;BR /&gt;
   cards;&lt;BR /&gt;
1 08/01/2009&lt;BR /&gt;
1 08/03/2009&lt;BR /&gt;
1 08/03/2009&lt;BR /&gt;
1 08/05/2009&lt;BR /&gt;
1 08/08/2009&lt;BR /&gt;
1 08/08/2009&lt;BR /&gt;
1 08/08/2009&lt;BR /&gt;
2 08/02/2009&lt;BR /&gt;
2 08/05/2009&lt;BR /&gt;
2 08/05/2009&lt;BR /&gt;
2 08/09/2009&lt;BR /&gt;
3 08/10/2009&lt;BR /&gt;
3 08/11/2009&lt;BR /&gt;
3 08/12/2009&lt;BR /&gt;
3 08/12/2009&lt;BR /&gt;
ods listing close;&lt;BR /&gt;
proc freq data=test levels;&lt;BR /&gt;
   table date /out=counts noprint;&lt;BR /&gt;
   by id;&lt;BR /&gt;
   *where month=8;&lt;BR /&gt;
   title 'August Days';&lt;BR /&gt;
   ods output nlevels=nlevels;&lt;BR /&gt;
   run;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc print data=nlevels;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Tue, 22 Sep 2009 16:08:19 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2009-09-22T16:08:19Z</dc:date>
    <item>
      <title>Count while skipping duplicates in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72646#M15647</link>
      <description>Is there a way to do a count by ID of unique dates while ignoring duplicate dates using proc freq?&lt;BR /&gt;
&lt;BR /&gt;
I just want to count each date one time although it can be used more than once.  I  need a total count of dates by ID, skipping over the duplicate dates.&lt;BR /&gt;
&lt;BR /&gt;
It sounds simple enough, but I cannot seem to get it right.  I need to get these totals on a bi-monthly basis.&lt;BR /&gt;
&lt;BR /&gt;
  proc freq data=test noprint;&lt;BR /&gt;
   table date /out=counts ;&lt;BR /&gt;
   by id;&lt;BR /&gt;
   where month=8;&lt;BR /&gt;
   title 'August Days';&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
This does the count for each date, but I now need to total the number of dates counting each date once.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for any suggestions!</description>
      <pubDate>Tue, 22 Sep 2009 13:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72646#M15647</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2009-09-22T13:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Count while skipping duplicates in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72647#M15648</link>
      <description>I'm not sure I understand your data.  If you succeed, won't your COUNTS all be 1?&lt;BR /&gt;
&lt;BR /&gt;
In any event, you might want to "clean" the data file first by using SORT with the NODUPKEY option.</description>
      <pubDate>Tue, 22 Sep 2009 14:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72647#M15648</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-22T14:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: Count while skipping duplicates in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72648#M15649</link>
      <description>Well, the duplicates are ok in the dataset so it doesnt' need to be cleaned.  I just want a count of the total number of unique dates by ID, not a count of the number of times a date exists for each ID.  &lt;BR /&gt;
&lt;BR /&gt;
I want a count for each month, see sample data:&lt;BR /&gt;
&lt;BR /&gt;
ID DATE&lt;BR /&gt;
1  08/01/2009&lt;BR /&gt;
1  08/03/2009&lt;BR /&gt;
1  08/03/2009&lt;BR /&gt;
1  08/05/2009&lt;BR /&gt;
1  08/08/2009&lt;BR /&gt;
1  08/08/2009&lt;BR /&gt;
1  08/08/2009&lt;BR /&gt;
2  08/02/2009&lt;BR /&gt;
2  08/05/2009&lt;BR /&gt;
2  08/05/2009&lt;BR /&gt;
2  08/09/2009&lt;BR /&gt;
3  08/10/2009&lt;BR /&gt;
3  08/11/2009&lt;BR /&gt;
3  08/12/2009&lt;BR /&gt;
3  08/12/2009&lt;BR /&gt;
&lt;BR /&gt;
The total number of dates for ID1 = 4, ID2 =3, ID3 = 3

Message was edited by: statadm</description>
      <pubDate>Tue, 22 Sep 2009 14:07:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72648#M15649</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2009-09-22T14:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: Count while skipping duplicates in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72649#M15650</link>
      <description>proc sql;&lt;BR /&gt;
 create table xxxx as select ID, month, count(distinct date) as cnt from yyyy &lt;BR /&gt;
group by id, month;&lt;BR /&gt;
quit;</description>
      <pubDate>Tue, 22 Sep 2009 15:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72649#M15650</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-09-22T15:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Count while skipping duplicates in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72650#M15651</link>
      <description>I meant "cleaned" as a possible approach to the problem.  If you elminated the "duplicates" and saved the result in a temp file, then the temp file could be usd for counting purposes.</description>
      <pubDate>Tue, 22 Sep 2009 15:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72650#M15651</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-22T15:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Count while skipping duplicates in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72651#M15652</link>
      <description>Thanks Flip, it works great.&lt;BR /&gt;
&lt;BR /&gt;
Sorry about the misunderstanding concerning cleaning the data.</description>
      <pubDate>Tue, 22 Sep 2009 15:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72651#M15652</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2009-09-22T15:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Count while skipping duplicates in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72652#M15653</link>
      <description>PROC FREQ will give you those count using the LEVELS proc statement option.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
   input ID DATE:mmddyy.;&lt;BR /&gt;
   cards;&lt;BR /&gt;
1 08/01/2009&lt;BR /&gt;
1 08/03/2009&lt;BR /&gt;
1 08/03/2009&lt;BR /&gt;
1 08/05/2009&lt;BR /&gt;
1 08/08/2009&lt;BR /&gt;
1 08/08/2009&lt;BR /&gt;
1 08/08/2009&lt;BR /&gt;
2 08/02/2009&lt;BR /&gt;
2 08/05/2009&lt;BR /&gt;
2 08/05/2009&lt;BR /&gt;
2 08/09/2009&lt;BR /&gt;
3 08/10/2009&lt;BR /&gt;
3 08/11/2009&lt;BR /&gt;
3 08/12/2009&lt;BR /&gt;
3 08/12/2009&lt;BR /&gt;
ods listing close;&lt;BR /&gt;
proc freq data=test levels;&lt;BR /&gt;
   table date /out=counts noprint;&lt;BR /&gt;
   by id;&lt;BR /&gt;
   *where month=8;&lt;BR /&gt;
   title 'August Days';&lt;BR /&gt;
   ods output nlevels=nlevels;&lt;BR /&gt;
   run;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc print data=nlevels;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 22 Sep 2009 16:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-while-skipping-duplicates-in-proc-freq/m-p/72652#M15653</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-09-22T16:08:19Z</dc:date>
    </item>
  </channel>
</rss>

