<?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 can I select and return the last value in the group? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-select-and-return-the-last-value-in-the-group/m-p/495765#M130921</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data testtt;
Input group x1;
Cards;
1 1
1 10
1 30
2 100
2 1000
2 1200
3 30
3 43
3 77
;
Run;

proc sql;

create table want as

select *,max(x1) as max

from testtt

group by group;

quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;biggest number&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as&lt;/P&gt;
&lt;P&gt;select *,max(x1) as max&lt;/P&gt;
&lt;P&gt;from have&lt;/P&gt;
&lt;P&gt;group by group;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Sep 2018 17:00:33 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-09-14T17:00:33Z</dc:date>
    <item>
      <title>How can I select and return the last value in the group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-select-and-return-the-last-value-in-the-group/m-p/495763#M130920</link>
      <description>&lt;P&gt;Hi. this must be very basic question.&lt;/P&gt;&lt;P&gt;But I'm dealing with it for about... 12 hours. And I couldn't find the answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data testtt;
Input group x1;
Cards;
1 1
1 10
1 30
2 100
2 1000
2 1200
3 30
3 43
3 77
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the data above, I'd like to make a new variable which shows the last value of each group. (Or the biggest number of each group is also fine)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it should be the data like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Result;
Input group x1 last;
Cards;
1 1 30
1 10 30
1 30 30
2 100 1200
2 1000 1200
2 1200 1200
3 30 77
3 43 77
3 77 77
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This must be the basic thing in SAS, but I couldn't find the way in SAS HELP or Google (or at least I don't know what to search...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 16:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-select-and-return-the-last-value-in-the-group/m-p/495763#M130920</guid>
      <dc:creator>MonoLight</dc:creator>
      <dc:date>2018-09-14T16:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I select and return the last value in the group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-select-and-return-the-last-value-in-the-group/m-p/495765#M130921</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data testtt;
Input group x1;
Cards;
1 1
1 10
1 30
2 100
2 1000
2 1200
3 30
3 43
3 77
;
Run;

proc sql;

create table want as

select *,max(x1) as max

from testtt

group by group;

quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;biggest number&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as&lt;/P&gt;
&lt;P&gt;select *,max(x1) as max&lt;/P&gt;
&lt;P&gt;from have&lt;/P&gt;
&lt;P&gt;group by group;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 17:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-select-and-return-the-last-value-in-the-group/m-p/495765#M130921</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-14T17:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I select and return the last value in the group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-select-and-return-the-last-value-in-the-group/m-p/495767#M130922</link>
      <description>&lt;P&gt;Thank you very much novinosrin!&lt;/P&gt;&lt;P&gt;Sql! That's what I should have learnt!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a nice day !&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 17:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-select-and-return-the-last-value-in-the-group/m-p/495767#M130922</guid>
      <dc:creator>MonoLight</dc:creator>
      <dc:date>2018-09-14T17:05:35Z</dc:date>
    </item>
  </channel>
</rss>

