<?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: calculate the maximum value of a variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/calculate-the-maximum-value-of-a-variable/m-p/59795#M16886</link>
    <description>It can be done with datastep (by retaining the maximum value for example), but it is easier and clearer to be done through proc sql or even proc summary/means.&lt;BR /&gt;
&lt;BR /&gt;
Give a look at the documentation of the RETAIN statement:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000214163.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000214163.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
    <pubDate>Wed, 29 Jul 2009 14:07:47 GMT</pubDate>
    <dc:creator>DanielSantos</dc:creator>
    <dc:date>2009-07-29T14:07:47Z</dc:date>
    <item>
      <title>calculate the maximum value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/calculate-the-maximum-value-of-a-variable/m-p/59794#M16885</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
Can we calculate the maximum value of a variable, in the data statement? &lt;BR /&gt;
I don't want to use Proc means, since I need to merge this maximum value back to my dataset.&lt;BR /&gt;
&lt;BR /&gt;
e.g. in the following dataset, do we have any function like &lt;BR /&gt;
&lt;BR /&gt;
max_v2 = max( v2 ) ,         ??&lt;BR /&gt;
&lt;BR /&gt;
-----------------------------&lt;BR /&gt;
id  v2&lt;BR /&gt;
&lt;BR /&gt;
1   2&lt;BR /&gt;
2   4&lt;BR /&gt;
3   5&lt;BR /&gt;
4   3&lt;BR /&gt;
5   4&lt;BR /&gt;
6   5&lt;BR /&gt;
7   6&lt;BR /&gt;
8   3&lt;BR /&gt;
&lt;BR /&gt;
--------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
Thanks!!&lt;BR /&gt;
&lt;BR /&gt;
Ken</description>
      <pubDate>Wed, 29 Jul 2009 13:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/calculate-the-maximum-value-of-a-variable/m-p/59794#M16885</guid>
      <dc:creator>Ken_oy</dc:creator>
      <dc:date>2009-07-29T13:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the maximum value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/calculate-the-maximum-value-of-a-variable/m-p/59795#M16886</link>
      <description>It can be done with datastep (by retaining the maximum value for example), but it is easier and clearer to be done through proc sql or even proc summary/means.&lt;BR /&gt;
&lt;BR /&gt;
Give a look at the documentation of the RETAIN statement:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000214163.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000214163.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
      <pubDate>Wed, 29 Jul 2009 14:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/calculate-the-maximum-value-of-a-variable/m-p/59795#M16886</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-07-29T14:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the maximum value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/calculate-the-maximum-value-of-a-variable/m-p/59796#M16887</link>
      <description>Ken,&lt;BR /&gt;
&lt;BR /&gt;
You don't say what you want to do with this maximum, so it is a bit hard to advise you.  For example, you could figure out the maximum in a data step, but it wouldn't be known for sure until you get to the last observation.  You could make an initial pass through the data file using the POINT option.  Or, you could also use SQL:&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
create table NEW as&lt;BR /&gt;
select *, max(v2) as max_v2&lt;BR /&gt;
from ORIGINAL&lt;BR /&gt;
;&lt;BR /&gt;
quit;</description>
      <pubDate>Wed, 29 Jul 2009 14:09:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/calculate-the-maximum-value-of-a-variable/m-p/59796#M16887</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-07-29T14:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the maximum value of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/calculate-the-maximum-value-of-a-variable/m-p/59797#M16888</link>
      <description>Thanks Kmg!!&lt;BR /&gt;
&lt;BR /&gt;
This is exactly what I want!!&lt;BR /&gt;
&lt;BR /&gt;
Thanks again! Problem FIXED!!</description>
      <pubDate>Wed, 29 Jul 2009 14:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/calculate-the-maximum-value-of-a-variable/m-p/59797#M16888</guid>
      <dc:creator>Ken_oy</dc:creator>
      <dc:date>2009-07-29T14:40:51Z</dc:date>
    </item>
  </channel>
</rss>

