<?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: Group by Count in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724363#M224893</link>
    <description>&lt;P&gt;How does your results differ from your desired results?&lt;/P&gt;</description>
    <pubDate>Mon, 08 Mar 2021 05:49:50 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2021-03-08T05:49:50Z</dc:date>
    <item>
      <title>Group by Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724360#M224891</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data gcount;
set cl;
 by age;
	if first.age then counts=0;
	counts+1;
	if last.age the output;
proc print;	title 'Age Group count with Datastep';
	run;

	proc freq data=cl  ;
	 tables Age*Sex format=2.0 /out=ccc(drop=percent) nopercent norow nocum ;
	run;

	proc sql;
	select  Age,count(Age) as counts from sashelp.class	
	group by  Age;
	title 'Age Group count with proc sql';
	quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here i want same output like Datastep in proc freq and proc sql&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 05:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724360#M224891</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2021-03-08T05:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724362#M224892</link>
      <description>&lt;OL&gt;
&lt;LI&gt;Please post data in usable form.&lt;/LI&gt;
&lt;LI&gt;Explain the problem: how does the result doesn't match your expectations.&lt;/LI&gt;
&lt;LI&gt;If you have a working solution, why wasting time in re-implementing it?&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 08 Mar 2021 05:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724362#M224892</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-03-08T05:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724363#M224893</link>
      <description>&lt;P&gt;How does your results differ from your desired results?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 05:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724363#M224893</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-03-08T05:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724371#M224894</link>
      <description>Keep name sex age height weight and age group count variables like datastep output in proc freq and proc sql methods</description>
      <pubDate>Mon, 08 Mar 2021 06:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724371#M224894</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2021-03-08T06:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724383#M224896</link>
      <description>&lt;P&gt;In Proc SQL;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   select  *, count(Age) as counts from sashelp.class	
   group by  Age;
   title 'Age Group count with proc sql';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Mar 2021 06:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724383#M224896</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-03-08T06:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724403#M224897</link>
      <description>&lt;P&gt;As per your code output get like below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Anandkvn_1-1615187918464.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55631i04A2A28EF6A968AB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Anandkvn_1-1615187918464.png" alt="Anandkvn_1-1615187918464.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I want output like below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Anandkvn_0-1615187840247.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55630i8B92E09ADF59D17A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Anandkvn_0-1615187840247.png" alt="Anandkvn_0-1615187840247.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 07:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724403#M224897</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2021-03-08T07:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724406#M224899</link>
      <description>&lt;P&gt;Why do you want to display the columns Name, Sex, Height and Weight?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=sashelp.class nway;
  class Age;
  output out=work.counted(drop= _type_ rename=(_freq_=count));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Mar 2021 07:39:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724406#M224899</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-03-08T07:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Group by Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724424#M224908</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Anandkvn_0-1615187840247.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55630i8B92E09ADF59D17A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Anandkvn_0-1615187840247.png" alt="Anandkvn_0-1615187840247.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Output like that is clearly in the domain of the data step. Only a "SAS illiterate" would waste time even thinking about doing it with a different tool.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mind that such a result depends on the way the data was sorted before the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SQL, you would need to make use of automatic remerge and a HAVING clause to filter for the "last" observation within a BY group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With PROC FREQ, you will need an additional step that adds the columns to the FREQ output (which will only contain the TABLES variables and the statistics), and for that need to prepare data (one obs per group) with a step that is basically the same you already have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 08:34:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Count/m-p/724424#M224908</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-08T08:34:40Z</dc:date>
    </item>
  </channel>
</rss>

