<?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: Display all observations from first. last. by grouping in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418812#M102913</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/112309"&gt;@kmj636&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I really apologize and appreciate your view and time. Yes, it should be and is "then output."&lt;/P&gt;
&lt;P&gt;I am still not able to see the contributing observations to the totals from the by groups.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Even though your code was incorrect and omitted the word "then", if you remove this line entirely, you will see the contributing observations.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Dec 2017 14:56:09 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2017-12-06T14:56:09Z</dc:date>
    <item>
      <title>Display all observations from first. last. by grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418497#M102812</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am merging two data sets and I am creating two Vars based on the first. last. by groups. Everything is merging fine, the newly created Vars and totaling fine, but my output is only displaying the totals or rather the final observation from each by group. I would like all the observations within each by group displayed in addition to the total and I know there is a way to do this but I can not find it in my notes or online anywhere.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is pretty basic:&lt;/P&gt;&lt;P&gt;Data set;&lt;/P&gt;&lt;P&gt;merge one two;&lt;/P&gt;&lt;P&gt;by animal name age;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if first.age then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; totpounds=0;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;totpounds+pounds;&lt;/P&gt;&lt;P&gt;if last.age output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are dummy Vars but basically that's the idea. Any help would truly be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 15:14:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418497#M102812</guid>
      <dc:creator>kmj636</dc:creator>
      <dc:date>2017-12-05T15:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Display all observations from first. last. by grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418499#M102813</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/112309"&gt;@kmj636&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;... but my output is only displaying the totals or rather the final observation from each by group ...&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is happening because you are telling SAS to only ouptut the final observation from each group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you take out the statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if last.age then output;&lt;/PRE&gt;
&lt;P&gt;then it won't happen.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 15:22:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418499#M102813</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-12-05T15:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Display all observations from first. last. by grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418503#M102814</link>
      <description>&lt;P&gt;What do you mean by total on each observation, do you mean incremental, or sum() all on every line?&amp;nbsp; For incremental you can do it in the one step:&lt;/P&gt;
&lt;PRE&gt;data want;    
  merge one two;
  by animal name age;
  totpounds=ifn(first.age,pounds,totpounds+pounds);
run;&lt;/PRE&gt;
&lt;P&gt;If you want the total on each row, then do that in a separate step and merge back e.g:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create WANT as
  select   A.*,
           B.TOT
  from     HAVE A
  left join (select AGE,sum(POUNDS) as TOT from HAVE group by AGE) B
  on        A.AGE=B.AGE;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 15:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418503#M102814</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-05T15:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: Display all observations from first. last. by grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418504#M102815</link>
      <description>&lt;P&gt;I really apologize and appreciate your view and time. Yes, it should be and is "then output."&lt;/P&gt;&lt;P&gt;I am still not able to see the contributing observations to the totals from the by groups.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 15:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418504#M102815</guid>
      <dc:creator>kmj636</dc:creator>
      <dc:date>2017-12-05T15:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Display all observations from first. last. by grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418507#M102817</link>
      <description>&lt;P&gt;You are wonderful! Thank you so much.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 15:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418507#M102817</guid>
      <dc:creator>kmj636</dc:creator>
      <dc:date>2017-12-05T15:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Display all observations from first. last. by grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418812#M102913</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/112309"&gt;@kmj636&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I really apologize and appreciate your view and time. Yes, it should be and is "then output."&lt;/P&gt;
&lt;P&gt;I am still not able to see the contributing observations to the totals from the by groups.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Even though your code was incorrect and omitted the word "then", if you remove this line entirely, you will see the contributing observations.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 14:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-all-observations-from-first-last-by-grouping/m-p/418812#M102913</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-12-06T14:56:09Z</dc:date>
    </item>
  </channel>
</rss>

