<?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: Counting N by Each UNIQUE in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Counting-N-by-Each-UNIQUE/m-p/622585#M4970</link>
    <description>&lt;P&gt;Sure, &lt;A href="https://go.documentation.sas.com/?docsetId=imlug&amp;amp;docsetTarget=imlug_langref_sect519.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en" target="_self"&gt;Use CALL TABULATE&lt;/A&gt; to get the unique values and the counts in one call:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
call randseed(1);
x=randfun(5000,"poi",1000);
call tabulate(values, count, x);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 06 Feb 2020 00:17:03 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2020-02-06T00:17:03Z</dc:date>
    <item>
      <title>Counting N by Each UNIQUE</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Counting-N-by-Each-UNIQUE/m-p/622573#M4969</link>
      <description>&lt;P&gt;UNIQUE picks all unique values, and COUNTUNIQUE counts the number of the unique values. For example,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
call randseed(1);
x=randfun(5000,"poi",1000);
ux=unique(x);
cux=countunique(x);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code simulates&amp;nbsp;&lt;EM&gt;X&lt;/EM&gt;~Poisson(1000) 5000 times. There are 187 unique values from 889 to 1108. Is there any efficient way to get the number of observations for each unique value? For example, 47 out of 5000 observations are &lt;EM&gt;X&lt;/EM&gt;=1000. I use&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to cux;
if i=1 then n=sum(x=ux[i]);
else n=n||sum(x=ux[i]);
end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but am looking for a better one.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2020 23:29:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Counting-N-by-Each-UNIQUE/m-p/622573#M4969</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-02-05T23:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Counting N by Each UNIQUE</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Counting-N-by-Each-UNIQUE/m-p/622585#M4970</link>
      <description>&lt;P&gt;Sure, &lt;A href="https://go.documentation.sas.com/?docsetId=imlug&amp;amp;docsetTarget=imlug_langref_sect519.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en" target="_self"&gt;Use CALL TABULATE&lt;/A&gt; to get the unique values and the counts in one call:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
call randseed(1);
x=randfun(5000,"poi",1000);
call tabulate(values, count, x);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Feb 2020 00:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Counting-N-by-Each-UNIQUE/m-p/622585#M4970</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-02-06T00:17:03Z</dc:date>
    </item>
  </channel>
</rss>

