<?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: Having Trouble in by group processing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-in-by-group-processing/m-p/462061#M117562</link>
    <description>&lt;P&gt;You're getting that result, because that's what the program is designed to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are several signs within the program that indicate you don't understand that this is what the program does.&amp;nbsp; If the program is designed to keep only one summary observation per CTYPE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Why not keep CTYPE as one of the variables being output?&lt;/LI&gt;
&lt;LI&gt;Why keep _OTHER since it is merely the last value being added into the total?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Bottom line:&amp;nbsp; the program doesn't do what you want.&amp;nbsp; It's not supposed to.&amp;nbsp; But you need to describe what you do want, if you would like some help.&lt;/P&gt;</description>
    <pubDate>Mon, 14 May 2018 14:32:37 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-05-14T14:32:37Z</dc:date>
    <item>
      <title>Having Trouble in by group processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-in-by-group-processing/m-p/462030#M117549</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to sum up&amp;nbsp;observations by group processing but after writing below code it's only giving me below the last line as output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;libname a "&amp;amp;path";&lt;BR /&gt;&lt;BR /&gt;proc sort data = a.data out=a.data1;
	by CTYPE;
Run;


data a.processing(keep=Sales _Other);
	set a.data1;
	by CTYPE;
	if first.CTYPE then Sales=0;
	Sales + _Other;
	&lt;STRONG&gt;if last.CTYPE;&lt;/STRONG&gt;
Run;

proc print data = a.processing;
run;&lt;/PRE&gt;&lt;P&gt;after running code, there was only last line number of group&amp;nbsp;produced as output.&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;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 13:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-in-by-group-processing/m-p/462030#M117549</guid>
      <dc:creator>gsavaliya92</dc:creator>
      <dc:date>2018-05-14T13:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble in by group processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-in-by-group-processing/m-p/462033#M117550</link>
      <description>&lt;P&gt;How many levels of CTYPE do you have? Show ud&amp;nbsp;some of your data and how your output data differ from what you expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Makes it much easier to help you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 13:22:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-in-by-group-processing/m-p/462033#M117550</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-05-14T13:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble in by group processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-in-by-group-processing/m-p/462039#M117554</link>
      <description>&lt;P&gt;Instead of using your own code (which can be a problem to write and fix bugs) to do this, you can get the information you need out of PROC MEANS or PROC SUMMARY. Since SAS has already done the work to program this type of summing over groups, there's no need for you to re-invent how to do it.&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 13:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-in-by-group-processing/m-p/462039#M117554</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-14T13:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble in by group processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-in-by-group-processing/m-p/462060#M117561</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209917"&gt;@gsavaliya92&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to sum up&amp;nbsp;observations by group processing but after writing below code it's only giving me below the last line as output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;libname a "&amp;amp;path";&lt;BR /&gt;&lt;BR /&gt;proc sort data = a.data out=a.data1;
	by CTYPE;
Run;


data a.processing(keep=Sales _Other);
	set a.data1;
	by CTYPE;
	if first.CTYPE then Sales=0;
	Sales + _Other;
	&lt;STRONG&gt;if last.CTYPE;&lt;/STRONG&gt;
Run;

proc print data = a.processing;
run;&lt;/PRE&gt;
&lt;P&gt;after running code, there was only last line number of group&amp;nbsp;produced as output.&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;Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your line of code&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if last.CTYPE;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Says "if this is the last value of the ctype group&amp;nbsp;then output the record". If you want all records remove that line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 14:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-in-by-group-processing/m-p/462060#M117561</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-14T14:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Having Trouble in by group processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-in-by-group-processing/m-p/462061#M117562</link>
      <description>&lt;P&gt;You're getting that result, because that's what the program is designed to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are several signs within the program that indicate you don't understand that this is what the program does.&amp;nbsp; If the program is designed to keep only one summary observation per CTYPE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Why not keep CTYPE as one of the variables being output?&lt;/LI&gt;
&lt;LI&gt;Why keep _OTHER since it is merely the last value being added into the total?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Bottom line:&amp;nbsp; the program doesn't do what you want.&amp;nbsp; It's not supposed to.&amp;nbsp; But you need to describe what you do want, if you would like some help.&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 14:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-Trouble-in-by-group-processing/m-p/462061#M117562</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-14T14:32:37Z</dc:date>
    </item>
  </channel>
</rss>

