<?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: Distinct Count in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Distinct-Count/m-p/316263#M5937</link>
    <description>&lt;P&gt;Do you want a data step program?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may presort the dataset by ID and flag. I used the grouped data by using NOTSORTED option in BY statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   do until(last.flag);
      set have;
      by id flag notsorted;
      if first.flag then do; pre_Code = Code; count = 1; end;
      else if pre_Code ^= Code then count + 1;
   end;
keep id flag count;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Dec 2016 14:50:40 GMT</pubDate>
    <dc:creator>KachiM</dc:creator>
    <dc:date>2016-12-02T14:50:40Z</dc:date>
    <item>
      <title>Distinct Count</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Distinct-Count/m-p/316008#M5931</link>
      <description>&lt;P&gt;I want to calculate distinct count by group. When i tried to create aggregate measure and use distinct count, it returns an error as variable is character (see the variable 'code' below)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 144pt;" border="0" width="192" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="3" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl66" style="height: 15.0pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="64" class="xl67" style="border-left: none; width: 48pt;"&gt;flag&lt;/TD&gt;
&lt;TD width="64" class="xl67" style="border-left: none; width: 48pt;"&gt;Code&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl68" style="height: 15.0pt; border-top: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;0&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;B1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl68" style="height: 15.0pt; border-top: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;0&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;B1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl68" style="height: 15.0pt; border-top: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;0&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;B2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl68" style="height: 15.0pt; border-top: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl68" style="height: 15.0pt; border-top: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl68" style="height: 15.0pt; border-top: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl68" style="height: 15.0pt; border-top: none; width: 48pt;"&gt;2&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;0&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;D1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl68" style="height: 15.0pt; border-top: none; width: 48pt;"&gt;2&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;0&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;D1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl68" style="height: 15.0pt; border-top: none; width: 48pt;"&gt;2&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-top: none; border-left: none; width: 48pt;"&gt;C1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD width="64" height="21" class="xl69" style="height: 15.75pt; border-top: none; width: 48pt;"&gt;2&lt;/TD&gt;
&lt;TD width="64" class="xl70" style="border-top: none; border-left: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD width="64" class="xl70" style="border-top: none; border-left: none; width: 48pt;"&gt;C1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to generate the following output in cross tab. &lt;STRONG&gt;For ID =1, it should return this output (i.e. distinct count of variable 'Code'.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="2" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl66" style="height: 15.0pt; width: 48pt;"&gt;flag&lt;/TD&gt;
&lt;TD width="64" class="xl67" style="border-left: none; width: 48pt;"&gt;Status&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl65" style="height: 15.0pt; border-top: none; width: 48pt;"&gt;0&lt;/TD&gt;
&lt;TD class="xl68" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl65" style="height: 15.0pt; border-top: none; width: 48pt;"&gt;1&lt;/TD&gt;
&lt;TD class="xl68" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would put ID in the drop down.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2016 18:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Distinct-Count/m-p/316008#M5931</guid>
      <dc:creator>Ujjawal</dc:creator>
      <dc:date>2016-12-01T18:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Distinct-Count/m-p/316263#M5937</link>
      <description>&lt;P&gt;Do you want a data step program?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may presort the dataset by ID and flag. I used the grouped data by using NOTSORTED option in BY statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   do until(last.flag);
      set have;
      by id flag notsorted;
      if first.flag then do; pre_Code = Code; count = 1; end;
      else if pre_Code ^= Code then count + 1;
   end;
keep id flag count;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 14:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Distinct-Count/m-p/316263#M5937</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2016-12-02T14:50:40Z</dc:date>
    </item>
  </channel>
</rss>

