<?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: Proc Report :  how to get distinct count of a variable in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53209#M6647</link>
    <description>Sounds like you want a summary reporting.  Have a look at the GROUP option on the DEFINE statement.&lt;BR /&gt;
&lt;BR /&gt;
Have a look at the search option on the SAS support website  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  or a Google advanced search using the keywords below will yield several matches with SAS DOC, technical papers (SGF, SUGI user conference).&lt;BR /&gt;
&lt;BR /&gt;
+"proc report" +summary site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
PROC REPORT DOC link:&lt;BR /&gt;
&lt;A href="http://support.sas.com/onlinedoc/913/getDoc/en/proc.hlp/a000068725.htm" target="_blank"&gt;http://support.sas.com/onlinedoc/913/getDoc/en/proc.hlp/a000068725.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
SUGI/SGF technical paper on PROC REPORT:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/forum2007/242-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/242-2007.pdf&lt;/A&gt;</description>
    <pubDate>Thu, 09 Oct 2008 15:09:10 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2008-10-09T15:09:10Z</dc:date>
    <item>
      <title>Proc Report :  how to get distinct count of a variable</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53205#M6643</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Can anyone explain how to code count(distinct) in proc report ?&lt;BR /&gt;
&lt;BR /&gt;
Amit</description>
      <pubDate>Thu, 09 Oct 2008 13:53:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53205#M6643</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-09T13:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report :  how to get distinct count of a variable</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53206#M6644</link>
      <description>Explain what you would like to see in your PROC REPORT output - a sample report illustration in your post might be helpful.&lt;BR /&gt;
&lt;BR /&gt;
Also, might I recommend using the SAS support website  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  and I did the Google advanced search below, which revealed some matches using your keyword references:&lt;BR /&gt;
&lt;BR /&gt;
+"proc report" +distinct +count site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
Have a look at the COMPUTE block to count BEFORE/AFTER a unique value&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 09 Oct 2008 14:08:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53206#M6644</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-10-09T14:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report :  how to get distinct count of a variable</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53207#M6645</link>
      <description>Let say, A monthly transaction dataset contains customer account number and account balance.This dataset may have multiple occurrences of an account number. How should i generate a report having total balance of only unique account numbers &lt;BR /&gt;
&lt;BR /&gt;
Does it make sense now ?&lt;BR /&gt;
&lt;BR /&gt;
Amit</description>
      <pubDate>Thu, 09 Oct 2008 14:21:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53207#M6645</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-09T14:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report :  how to get distinct count of a variable</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53208#M6646</link>
      <description>This ould be coded in Proc SQL something like this :&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table a xyz as&lt;BR /&gt;
select count(distinct acct) as accnum,&lt;BR /&gt;
          sum(balance) as balance&lt;BR /&gt;
&lt;BR /&gt;
from abc;&lt;BR /&gt;
quit</description>
      <pubDate>Thu, 09 Oct 2008 14:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53208#M6646</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-09T14:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report :  how to get distinct count of a variable</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53209#M6647</link>
      <description>Sounds like you want a summary reporting.  Have a look at the GROUP option on the DEFINE statement.&lt;BR /&gt;
&lt;BR /&gt;
Have a look at the search option on the SAS support website  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  or a Google advanced search using the keywords below will yield several matches with SAS DOC, technical papers (SGF, SUGI user conference).&lt;BR /&gt;
&lt;BR /&gt;
+"proc report" +summary site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
PROC REPORT DOC link:&lt;BR /&gt;
&lt;A href="http://support.sas.com/onlinedoc/913/getDoc/en/proc.hlp/a000068725.htm" target="_blank"&gt;http://support.sas.com/onlinedoc/913/getDoc/en/proc.hlp/a000068725.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
SUGI/SGF technical paper on PROC REPORT:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/forum2007/242-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/242-2007.pdf&lt;/A&gt;</description>
      <pubDate>Thu, 09 Oct 2008 15:09:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53209#M6647</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-10-09T15:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report :  how to get distinct count of a variable</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53210#M6648</link>
      <description>Hi:&lt;BR /&gt;
  As Scott hinted, with PROC REPORT, you would want a SUMMARY report (where each report row represented the "collapsing" or "summarization" of all the observations for a unique GROUP variable (or combination of GROUP/ORDER variables)).&lt;BR /&gt;
                             &lt;BR /&gt;
  For example, with this data:&lt;BR /&gt;
[pre]data bankinfo;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input acct amt;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
123 100&lt;BR /&gt;
123 150&lt;BR /&gt;
123 300&lt;BR /&gt;
456 200&lt;BR /&gt;
456 200&lt;BR /&gt;
890 100&lt;BR /&gt;
890 100&lt;BR /&gt;
890 100&lt;BR /&gt;
890  50&lt;BR /&gt;
991 100&lt;BR /&gt;
991 250&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                         &lt;BR /&gt;
[/pre]&lt;BR /&gt;
  &lt;BR /&gt;
  There are 11 observations in the data set, but only 4 unique account numbers.&lt;BR /&gt;
&lt;BR /&gt;
  So, this PROC REPORT, will produce a "summary" report:&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods listing close;&lt;BR /&gt;
ods html file='bankinfo.html' style=sasweb;&lt;BR /&gt;
proc report data=bankinfo nowd;&lt;BR /&gt;
  column acct amt n;&lt;BR /&gt;
  define acct / group;&lt;BR /&gt;
  define amt / sum f=comma6. "Balance Amt";&lt;BR /&gt;
  define n / 'Number of Obs';&lt;BR /&gt;
  rbreak after / summarize;&lt;BR /&gt;
  compute acct;&lt;BR /&gt;
    if _break_ = ' ' then cnt_uniq + 1;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  compute after /&lt;BR /&gt;
    style={just=l};&lt;BR /&gt;
    line 'Number of Accounts:' cnt_uniq 2.0;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
.... that has one report row for every unique value of account number. The RBREAK AFTER statement will put a "grand total" summary line at the bottom of the report. The LINE statement inside the COMPUTE block adds an explanatory line to the bottom of the report that shows what the total count of unique account numbers is. The CNT_UNIQ temporary variable is used to hold a "running" count of unique account numbers.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 10 Oct 2008 01:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-how-to-get-distinct-count-of-a-variable/m-p/53210#M6648</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-10-10T01:10:46Z</dc:date>
    </item>
  </channel>
</rss>

