<?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: how to count the frequency of each distinct y each day? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482665#M125062</link>
    <description>&lt;P&gt;Actually, this is same result as proc freq. But it is not exactly what I want, since it does not include the missing ones, such as the frequency of aa or aaa. I think I may have to add it manually. That is why I asked how to add a row in another post. Do you have a better idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jul 2018 01:08:14 GMT</pubDate>
    <dc:creator>xiangpang</dc:creator>
    <dc:date>2018-07-31T01:08:14Z</dc:date>
    <item>
      <title>how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482331#M124907</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to count the number of ID with distinct y in each day. Make a table like 'want'. Could anyone tell me how to do that? Thanks a lot!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;data eq;
input ID day y ;
cards;
1 1 a 
1 2 b 
1 3 c 
1 4 v 
2 1 a 
2 2 b 
2 3 cc 
2 4 v 
3 1 a 
3 2 bb 
3 3 c 
3 4 v  
4 1 a 
4 2 bb   
4 3 ccc 
4 4 vv 
5 1 a 
5 2 b 
5 3 ccc 
5 4 vvv
run;

want
day1    a 5
	aa 0
	aaa 0
day2    b 3
	bb 2
	bbb 0
day3    c 2
	cc 1
	ccc 2
day4    v 1
	vv 1
	vvv 3&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 02:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482331#M124907</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-07-30T02:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482339#M124914</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
&amp;nbsp; select day, y, count(distinct ID) from EQ group by 1,2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 03:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482339#M124914</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-07-30T03:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482340#M124915</link>
      <description>&lt;P&gt;BTW - it needs to be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input ID day y $;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And shouldn't Day 4 be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;day4    v 3
	vv 1
	vvv 1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How do you expect to derive values which aren't in the source data:&amp;nbsp;aa,&amp;nbsp;aaa,&amp;nbsp;bbb?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;That aside, most of what you want can be achieved with PROC FREQ options, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FREQ DATA = eq;
	TABLES day * y / NOROW NOCOL NOPERCENT NOCUM LIST;
	TABLES day * y / NOROW NOCOL NOPERCENT NOCUM CROSSLIST;
	TABLES day * y / NOROW NOCOL NOPERCENT NOCUM OUT=MyOutputTable;
RUN;
proc print data=MyOutputTable(drop=PERCENT) noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Check out PROC FREQ in the &lt;A href="http://support.sas.com/documentation/cdl/en/procstat/66703/HTML/default/viewer.htm#procstat_freq_toc.htm" target="_blank"&gt;SAS Online Documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 03:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482340#M124915</guid>
      <dc:creator>AndrewHowell</dc:creator>
      <dc:date>2018-07-30T03:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482487#M124985</link>
      <description>&lt;P&gt;By table do you mean a data set to manipulate further or a table for people to read. If the desire is something for people perhaps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=eq;
  class day y;
  tables day*y,
         n
   ;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Jul 2018 14:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482487#M124985</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-30T14:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482665#M125062</link>
      <description>&lt;P&gt;Actually, this is same result as proc freq. But it is not exactly what I want, since it does not include the missing ones, such as the frequency of aa or aaa. I think I may have to add it manually. That is why I asked how to add a row in another post. Do you have a better idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 01:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482665#M125062</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-07-31T01:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482668#M125064</link>
      <description>&lt;P&gt;There's no &lt;EM&gt;aa&lt;/EM&gt; in your data, how you expect that in the output?&lt;/P&gt;
&lt;P&gt;You 'll need a reference table with all the values.&lt;/P&gt;
&lt;P&gt;Then you can use this table in a join if you go the SQL route, or with PROC MEANS CLASSDATA= if you prefer a procedure.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 01:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482668#M125064</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-07-31T01:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482670#M125065</link>
      <description>&lt;P&gt;Thanks for your input. Do you mind to explain a little bit more or give a link? how to make a reference table? I prefer a procedure. how to use classdata= to do this job?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 02:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482670#M125065</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-07-31T02:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482675#M125068</link>
      <description>&lt;P&gt;I am sure you can find the link.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; &amp;nbsp;This works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data EQ;
input ID DAY Y $;
cards;
1 1 a 
1 2 b 
1 3 c 
1 4 v 
2 1 a 
2 2 b 
2 3 cc 
2 4 v 
3 1 a 
3 2 bb 
3 3 c 
3 4 v  
4 1 a 
4 2 bb   
4 3 ccc 
4 4 vv 
5 1 a 
5 2 b 
5 3 ccc 
5 4 vvv
run;
data CLASSDATA;
  input DAY Y $;
cards;
1 a 
1 aa 
1 aaa 
2 b 
2 bb 
2 bb 
3 c 
3 cc 
3 ccc
4 v
4 vv
4 vvv
run;
proc summary data=EQ(drop=ID) classdata=CLASSDATA nway n;
  class DAY Y;
  output out=WANT ( drop=_TYPE_);
run;
&lt;/CODE&gt;&lt;/PRE&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;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" style="height: 15.0pt; width: 48pt;"&gt;DAY&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Y&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;_FREQ_&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;1&lt;/TD&gt;
&lt;TD&gt;a&lt;/TD&gt;
&lt;TD align="right"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;1&lt;/TD&gt;
&lt;TD&gt;aa&lt;/TD&gt;
&lt;TD align="right"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;1&lt;/TD&gt;
&lt;TD&gt;aaa&lt;/TD&gt;
&lt;TD align="right"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;2&lt;/TD&gt;
&lt;TD&gt;b&lt;/TD&gt;
&lt;TD align="right"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;2&lt;/TD&gt;
&lt;TD&gt;bb&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;3&lt;/TD&gt;
&lt;TD&gt;c&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;3&lt;/TD&gt;
&lt;TD&gt;cc&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;3&lt;/TD&gt;
&lt;TD&gt;ccc&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;4&lt;/TD&gt;
&lt;TD&gt;v&lt;/TD&gt;
&lt;TD align="right"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;4&lt;/TD&gt;
&lt;TD&gt;vv&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;4&lt;/TD&gt;
&lt;TD&gt;vvv&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 31 Jul 2018 02:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482675#M125068</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-07-31T02:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482682#M125071</link>
      <description>&lt;P&gt;Thanks a lot .&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 03:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482682#M125071</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-07-31T03:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482683#M125072</link>
      <description>&lt;P&gt;Could I also use this method for unknown ID number with unknown variable number?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 03:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482683#M125072</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-07-31T03:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482684#M125073</link>
      <description>&lt;P&gt;What does this mean?&lt;/P&gt;
&lt;P&gt;Please give a &lt;STRONG&gt;precise and complete example&lt;/STRONG&gt; as it seems that your request keeps changing.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 03:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482684#M125073</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-07-31T03:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482689#M125076</link>
      <description>&lt;P&gt;Sorry for the confusion. Maybe it should be another question. The example only have 5 IDs with 4 different date and 4 different value for Y. However, in real case, when I have thousands of IDs with a hundred different Y, what is the easiest way to create the &lt;SPAN&gt;classdata&lt;/SPAN&gt;?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 03:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482689#M125076</guid>
      <dc:creator>xiangpang</dc:creator>
      <dc:date>2018-07-31T03:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of each distinct y each day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482692#M125078</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;nbsp;what is the easiest way to create the&amp;nbsp;classdata?&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't know.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Who decides that day 1 only has Y= a, aa, and aaa? &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Where are these&amp;nbsp;chosen&amp;nbsp;combinations coming from?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How do you tell the program?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 04:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-each-distinct-y-each-day/m-p/482692#M125078</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-07-31T04:13:27Z</dc:date>
    </item>
  </channel>
</rss>

