<?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 age in datastep in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632124#M77778</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a data step equivalent to your PROC SQL code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*PROC SQL */

proc sql;
	create table want as /* &amp;lt;-- add this code if you want to output a dataset */
	select age, count(age) as Age_N from sashelp.class 
	group by age;
quit;


/* DATA STEP EQUIVALENT */

proc sort data=sashelp.class out=class_sorted;
	by age;
run;

proc means data=class_sorted n nonobs;
	var age;
	class age;
	ways 1;
	output out=want (drop=_:) n= /autoname; /* &amp;lt;-- add this code if you want to output a dataset */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All the best,&lt;/P&gt;</description>
    <pubDate>Sat, 14 Mar 2020 08:39:57 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-03-14T08:39:57Z</dc:date>
    <item>
      <title>group by age in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632102#M77773</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dd;
set sashelp.class;
run;

proc sql;
	select age, count(age) from dd 
group by  age;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;i want output in datastep group by age as well as name of age of agecount&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 04:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632102#M77773</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2020-03-14T04:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: group by age in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632113#M77775</link>
      <description>&lt;P&gt;What do you mean by "name of age"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And is your question how to re-engineer the sql code in a data step?&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 06:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632113#M77775</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-14T06:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: group by age in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632120#M77776</link>
      <description>&lt;P&gt;Hi Krut,&lt;/P&gt;&lt;P&gt;I want same result like in datastep like proc sql&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select age, count(age) as agecount from sashelp.class&lt;BR /&gt;group by age;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 07:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632120#M77776</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2020-03-14T07:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: group by age in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632122#M77777</link>
      <description>&lt;P&gt;First, sort by age. Then use a data step with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;by age;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;retain the new variable agecount, set it to 1 at first.age, and increment it else. At last.age, output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See examples for the use of by in a data step here:&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p0yeyftk8ftuckn1o5qzy53284gz.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p0yeyftk8ftuckn1o5qzy53284gz.htm&amp;amp;locale=en&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 07:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632122#M77777</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-14T07:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: group by age in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632124#M77778</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a data step equivalent to your PROC SQL code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*PROC SQL */

proc sql;
	create table want as /* &amp;lt;-- add this code if you want to output a dataset */
	select age, count(age) as Age_N from sashelp.class 
	group by age;
quit;


/* DATA STEP EQUIVALENT */

proc sort data=sashelp.class out=class_sorted;
	by age;
run;

proc means data=class_sorted n nonobs;
	var age;
	class age;
	ways 1;
	output out=want (drop=_:) n= /autoname; /* &amp;lt;-- add this code if you want to output a dataset */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All the best,&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 08:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632124#M77778</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-14T08:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: group by age in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632154#M77783</link>
      <description>&lt;P&gt;This isn't a great idea for a data step either, the 'SAS' method to do this would be to use PROC FREQ (or REPORT, TABULATE, MEANS). This provides displayed output or a dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=sashelp.class;
table age / out = want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.class N;
class age;
output out=want_means N= ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&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;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dd;
set sashelp.class;
run;

proc sql;
	select age, count(age) from dd 
group by  age;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;i want output in datastep group by age as well as name of age of agecount&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2020 15:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/group-by-age-in-datastep/m-p/632154#M77783</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-14T15:12:23Z</dc:date>
    </item>
  </channel>
</rss>

