<?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: max() group by without sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167563#M300880</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have not, I am not familiar with getting this result using proc means.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Jan 2015 22:37:43 GMT</pubDate>
    <dc:creator>Steelers_In_DC</dc:creator>
    <dc:date>2015-01-01T22:37:43Z</dc:date>
    <item>
      <title>max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167561#M300878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Happy New Year,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to perform the following using sas code, not proc sql.&amp;nbsp; I know using the max function for two variables and a group by statement would work but I'm looking for another solution.&amp;nbsp; Thank You in advance:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards dsd;&lt;/P&gt;&lt;P&gt;informat date mmddyy10.;&lt;/P&gt;&lt;P&gt;format date date9.; &lt;/P&gt;&lt;P&gt;input acct $ date default $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;00001,01/01/2000,pd npl&lt;/P&gt;&lt;P&gt;00001,01/01/2000,pd&lt;/P&gt;&lt;P&gt;00001,01/01/2001,pd&lt;/P&gt;&lt;P&gt;00002,02/01/2000,pd npl&lt;/P&gt;&lt;P&gt;00002,02/01/2000,pd&lt;/P&gt;&lt;P&gt;00002,02/01/2010,pd&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;infile cards dsd;&lt;/P&gt;&lt;P&gt;informat date mmddyy10.;&lt;/P&gt;&lt;P&gt;format date date9.; &lt;/P&gt;&lt;P&gt;input acct $ date default $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;00001,01/01/2001,pd npl&lt;/P&gt;&lt;P&gt;00002,02/01/2010,pd npl&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jan 2015 22:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167561#M300878</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-01-01T22:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167562#M300879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gave you looked at &lt;/P&gt;&lt;P&gt;PROC MEANS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jan 2015 22:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167562#M300879</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2015-01-01T22:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167563#M300880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have not, I am not familiar with getting this result using proc means.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jan 2015 22:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167563#M300880</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-01-01T22:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167564#M300881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think proc means will work because of the text variables. &lt;/P&gt;&lt;P&gt;Whats the logic, max of each field? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jan 2015 22:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167564#M300881</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-01T22:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167565#M300882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want the most recent date for the date field and the longest length for the default field.&amp;nbsp; I believe the sql max() performs the same way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jan 2015 22:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167565#M300882</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-01-01T22:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167566#M300883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sort data=have;&lt;/P&gt;&lt;P&gt;by acct date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(drop=default rename=default1=default);&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by acct date default notsorted;&lt;/P&gt;&lt;P&gt;retain default1;&lt;/P&gt;&lt;P&gt;if first.acct then default1=default;&lt;/P&gt;&lt;P&gt;if last.acct;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jan 2015 23:13:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167566#M300883</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-01-01T23:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167567#M300884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;stat@sas, very nice.&amp;nbsp; Thank you very much.&amp;nbsp; If you wouldn't mind can you explain why this works the way that it does?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank You,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jan 2015 23:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167567#M300884</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-01-01T23:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167568#M300885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As dataset is sorted by acct and date. Last date within each value of acct variable will be the maximum one. Introduced a new variable default1 assigned maximum value of default variable at the first occurrence of each value of acct and retained until the last occurrence.&amp;nbsp; Finally, &lt;STRONG&gt;if last&lt;/STRONG&gt; condition outputs the last occurrence of each acct value along with maximum date and maximum value of default variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hoping to see Steelers in super bowl this year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Naeem&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Jan 2015 23:59:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167568#M300885</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-01-01T23:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167569#M300886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;haha, me too!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having one issue.&amp;nbsp; The default field is null in some cases.&amp;nbsp; Where this happens the result is always null.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jan 2015 00:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167569#M300886</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-01-02T00:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167570#M300887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The answer from @stat@sas isn't a true max, but it takes the first record.&amp;nbsp; Simply switching the first two records in your sample data will break the logic. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're looking for the true max from each field you can do two sorts/passes of the data or use first/last and manually calculate one. See an example below, of breaking the solution as well as an alternative. If your data was pre-sorted by acct already you could manually&amp;nbsp; calculate each max similarly. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; have;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;infile&lt;SPAN style="color: #000000;"&gt; cards &lt;/SPAN&gt;dsd&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #009193;"&gt;&lt;SPAN style="color: #0433ff;"&gt;informat&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; date &lt;/SPAN&gt;mmddyy10.&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;format&lt;/SPAN&gt; date &lt;SPAN style="color: #009193;"&gt;date9.&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;input&lt;/SPAN&gt; acct $ date default $;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;cards&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;00001,01/01/2000,pd&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;00001,01/01/2000,pd npl&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;00001,01/01/2001,pd&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;00002,02/01/2000,pd npl&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;00002,02/01/2000,pd&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;00002,02/01/2010,pd&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;sort&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;data&lt;/SPAN&gt;=have;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;by&lt;/SPAN&gt; acct date;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; want(drop=default rename=default1=default);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;set&lt;/SPAN&gt; have;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;by&lt;/SPAN&gt; acct date default &lt;SPAN style="color: #0433ff;"&gt;notsorted&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;retain&lt;/SPAN&gt; default1;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; first.acct &lt;SPAN style="color: #0433ff;"&gt;then&lt;/SPAN&gt; default1=default;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; last.acct;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;*Manually calculating max assuming a sorted dataset, by acct date;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; want2;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;set&lt;/SPAN&gt; have;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;by&lt;/SPAN&gt; acct date;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;retain&lt;/SPAN&gt; max_default;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; first.acct &lt;SPAN style="color: #0433ff;"&gt;then&lt;/SPAN&gt; max_default=default;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;else&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; default&amp;gt;max_default &lt;SPAN style="color: #0433ff;"&gt;then&lt;/SPAN&gt; max_default=default;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; last.acct;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;drop&lt;/SPAN&gt; default;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;rename&lt;/SPAN&gt; max_default=default;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New'; font-size: 8pt;"&gt;*Manually calculating max, assuming sorted only by acct;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New'; font-size: 8pt;"&gt;*You'll need to do the rename/dropping of variables;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; want3;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;set&lt;/SPAN&gt; have;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;by&lt;SPAN style="color: #000000;"&gt; acct &lt;/SPAN&gt;notsorted&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;retain&lt;/SPAN&gt; max_date max_default;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; first.acct &lt;SPAN style="color: #0433ff;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;do&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp; max_default=default;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp; max_date=date;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;else&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;do&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; default&amp;gt;max_default &lt;SPAN style="color: #0433ff;"&gt;then&lt;/SPAN&gt; max_default=default;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; date&amp;gt;max_date &lt;SPAN style="color: #0433ff;"&gt;then&lt;/SPAN&gt; max_date=date;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; last.acct;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jan 2015 00:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167570#M300887</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-02T00:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167571#M300888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Very nice, thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jan 2015 01:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167571#M300888</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-01-02T01:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167572#M300889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As suggested solution was based on the given dataset and problem description. Reeza has raised on interesting point but not sure whether this is true for all of the text comparisons. A small modification in the syntax will fix the problem raised by Reeza as well as if the default field contains null values. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Naeem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have;&lt;/P&gt;&lt;P&gt;by acct date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(drop=default rename=default1=default);&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by acct date default notsorted;&lt;/P&gt;&lt;P&gt;length default1 $8.;&lt;/P&gt;&lt;P&gt;retain default1;&lt;/P&gt;&lt;P&gt;if first.acct then default1='';&lt;/P&gt;&lt;P&gt;if default='pd npl' then default1=default;&lt;/P&gt;&lt;P&gt;if last.acct;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jan 2015 01:55:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167572#M300889</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-01-02T01:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: max() group by without sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167573#M300890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Naeem your solution is too specific to the sample data, not to the actual programming problem.&amp;nbsp; What would happen if the text had an upper cased letter, extra leading or trailing space? And assume this is a sample of the problem that is meant to illustrate the problem, not the exact data/problem the OP is presenting. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem seems to be:&lt;/P&gt;&lt;P&gt;&lt;EM style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;I know using the max function for two variables and a group by statement would work but I'm looking for another solution. &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Or restated:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;How to find the max of two variables within a group NOT using proc sql.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Hope that makes sense!&lt;/SPAN&gt;&lt;EM style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Jan 2015 02:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-group-by-without-sql/m-p/167573#M300890</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-02T02:11:52Z</dc:date>
    </item>
  </channel>
</rss>

