<?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 to find the max value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-max-value/m-p/240861#M44524</link>
    <description>&lt;P&gt;Seems like you are trying to get maximum value of paidup_capital within each company_status.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;select&amp;nbsp;COMPANY_STATUS,max(_PAIDUP_CAPITAL_) as highest_paidup from auto21&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;where&amp;nbsp;COMPANY_STATUS='ACTIVE' AND COMPANY_CLASS='Public'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;group by&amp;nbsp;COMPANY_STATUS;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you want to get maximum value overall then try this&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;select max(_PAIDUP_CAPITAL_) as highest_paidup from auto21&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;where&amp;nbsp;COMPANY_STATUS='ACTIVE' AND COMPANY_CLASS='Public';&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Dec 2015 17:11:14 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2015-12-25T17:11:14Z</dc:date>
    <item>
      <title>how to find the max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-max-value/m-p/240855#M44521</link>
      <description>&lt;P&gt;hey All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT= WORK.auto21&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATAFILE= "C:\Documents and Settings\sasadm\Desktop\XXX.xls"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=EXCEL REPLACE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SHEET="company_master_data_mar_2015_De";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GETNAMES=YES;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MIXED=YES;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; USEDATE=YES;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCANTIME=YES;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=auto21 (where=(COMPANY_STATUS='ACTIVE' AND COMPANY_CLASS='Public')) out= ACT12;&lt;BR /&gt;by COMPANY_STATUS descending _PAIDUP_CAPITAL_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Till now i code is running fine..!! Now i want the highest paidup cap (Value) in data set...!! Please advise ..?&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;how can i go furthre ..???&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Dec 2015 10:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-max-value/m-p/240855#M44521</guid>
      <dc:creator>SAM_VAS</dc:creator>
      <dc:date>2015-12-25T10:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-max-value/m-p/240857#M44522</link>
      <description>&lt;P&gt;This can be done in different ways. For example you can use &lt;STRONG&gt;MEANS procedure&amp;nbsp;&lt;/STRONG&gt; to get the max min values for each variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Give example of your dataset and how you want it to be ... In order to get the best answer for your case.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Dec 2015 12:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-max-value/m-p/240857#M44522</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-12-25T12:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-max-value/m-p/240861#M44524</link>
      <description>&lt;P&gt;Seems like you are trying to get maximum value of paidup_capital within each company_status.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;select&amp;nbsp;COMPANY_STATUS,max(_PAIDUP_CAPITAL_) as highest_paidup from auto21&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;where&amp;nbsp;COMPANY_STATUS='ACTIVE' AND COMPANY_CLASS='Public'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;group by&amp;nbsp;COMPANY_STATUS;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you want to get maximum value overall then try this&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;select max(_PAIDUP_CAPITAL_) as highest_paidup from auto21&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;where&amp;nbsp;COMPANY_STATUS='ACTIVE' AND COMPANY_CLASS='Public';&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Dec 2015 17:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-max-value/m-p/240861#M44524</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-12-25T17:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-max-value/m-p/240867#M44530</link>
      <description>&lt;P&gt;Given that you are comfortable with sorting your data as a starting point, this would be one way to continue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data highest;&lt;/P&gt;
&lt;P&gt;set act12;&lt;/P&gt;
&lt;P&gt;by&amp;nbsp;&lt;SPAN&gt;COMPANY_STATUS descending _PAIDUP_CAPITAL_;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;if last.COMPANY_STATUS;&lt;/P&gt;
&lt;P&gt;max_paidup_capital =&amp;nbsp;&lt;SPAN&gt;_PAIDUP_CAPITAL_;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This would give you one observation per COMPANY_STATUS and discard the remaining observations.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If your intent is slightly different ... to add that max value to EVERY observation ... you could drop variables that aren't needed and then merge with ACT12. &amp;nbsp;However, note that a more sophisticated program originally can accomplish that in a single step. &amp;nbsp;After sorting but REMOVING the word DESCENDING from the original BY statement:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;do until (last,.COMPANY_STATUS);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;set act12;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;by company_status _paidup_capital_;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;max_paidup_capital = _paidup_capital_;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;do until (last.COMPANY_STATUS);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;set act12;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;by company_status;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;output;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Note that the SQL approaches are equally valid. &amp;nbsp;I just imagined that you would be more comfortable adding to your original approach.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Good luck.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Dec 2015 17:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-max-value/m-p/240867#M44530</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-12-25T17:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to find the max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-max-value/m-p/241025#M44587</link>
      <description>&lt;P&gt;With proc means or summary the data need not be sorted first if using a CLASS statement to group your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data = data=auto21 nway; /* NWAY says to only output the full combinations when using class variables, don't use if you want to examine all of the combinations of class variables*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* where is also a valid statement in some procs*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; where COMPANY_STATUS='ACTIVE' AND COMPANY_CLASS='Public';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; /* grouping variables*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class COMPANY_STATUS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; /* analysis variables*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var _PAIDUP_CAPITAL_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output out= act12(drop=_type_ _freq_) max=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;_type_ is a special variable that describes which combination of class variables the output record belongs to, _freq_ is how many records were examined to get the statistics.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 16:52:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-find-the-max-value/m-p/241025#M44587</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-12-28T16:52:37Z</dc:date>
    </item>
  </channel>
</rss>

