<?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: PROC SQL equivalent of TOP in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35623#M8809</link>
    <description>Check the OUTOBS= option with PROC SQL.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
proc sql select limit selected rows outobs site:sas.com</description>
    <pubDate>Tue, 22 Mar 2011 16:54:51 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2011-03-22T16:54:51Z</dc:date>
    <item>
      <title>PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35622#M8808</link>
      <description>Hello all;&lt;BR /&gt;
Proc SQL in SAS does not seem to support the TOP function in SQL, is there an equivalent work around here? I get multiple records when I do a match but I just need the first record.&lt;BR /&gt;
&lt;BR /&gt;
Thanks, &lt;BR /&gt;
&lt;BR /&gt;
Lawrence</description>
      <pubDate>Tue, 22 Mar 2011 16:41:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35622#M8808</guid>
      <dc:creator>_LB</dc:creator>
      <dc:date>2011-03-22T16:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35623#M8809</link>
      <description>Check the OUTOBS= option with PROC SQL.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
proc sql select limit selected rows outobs site:sas.com</description>
      <pubDate>Tue, 22 Mar 2011 16:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35623#M8809</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-03-22T16:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35624#M8810</link>
      <description>No.&lt;BR /&gt;
outobs= option of sql only can output top several obs.&lt;BR /&gt;
When Op want every top obs for every group ?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;DIV class="Section1" style=""&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal" style="text-align: left;" align="left"&gt;&lt;SPAN class="GramE"&gt;&lt;B&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;proc&lt;/SPAN&gt;&lt;/B&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt; &lt;/SPAN&gt;&lt;SPAN class="SpellE"&gt;&lt;B&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;sql&lt;/SPAN&gt;&lt;/B&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal" style="text-align: left;" align="left"&gt;&lt;SPAN class="GramE"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;create&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt; top &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal" style="text-align: left;" align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;&lt;SPAN style=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="GramE"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;select&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt; &lt;SPAN class="SpellE"&gt;region,sales&lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal" style="text-align: left;" align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;&lt;SPAN style=""&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="GramE"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;from&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt; &lt;SPAN class="SpellE"&gt;sashelp.shoes&lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal" style="text-align: left;" align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;&lt;SPAN style=""&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="GramE"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;group&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt; region&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal" style="text-align: left;" align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;&lt;SPAN style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="GramE"&gt;having&lt;/SPAN&gt;&lt;BR /&gt;
sales &lt;SPAN class="SpellE"&gt;eq&lt;/SPAN&gt; max(sales)&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal" style="text-align: left;" align="left"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;&lt;SPAN style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN class="GramE"&gt;&lt;B&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;quit&lt;/SPAN&gt;&lt;/B&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN class="SpellE"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: navy; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;Ksharp&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: navy;" lang="EN-US"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 23 Mar 2011 02:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35624#M8810</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-23T02:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35625#M8811</link>
      <description>Clearly, Ksharp read more from the OP than I...however I just don't see how the solution SAS program yields a "top N by group variable list", frankly, unless "N" is a value equal to obs that have the MAX(SALES) value, which could be one or more observations within a particular group list.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 23 Mar 2011 05:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35625#M8811</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-03-23T05:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35626#M8812</link>
      <description>Hi.SBB.If You want solution SAS program yields a "top N by group variable list",then try tp&lt;BR /&gt;
use proc univariate + nextrval option + class statement which I have mentioned before.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 23 Mar 2011 06:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35626#M8812</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-23T06:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35627#M8813</link>
      <description>If you want top N by group than you should just rank a variable by the given group.  Then just choose how far down to go in the rank.  Top 5 would be where rank&amp;lt;=5.</description>
      <pubDate>Wed, 23 Mar 2011 11:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35627#M8813</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2011-03-23T11:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35628#M8814</link>
      <description>OK,&lt;BR /&gt;
This thread is not helping the cause, as this is not what I am looking for-&lt;BR /&gt;
The problem is that, yes ina deta step I can easily take the first observation by a given variable, &lt;BR /&gt;
&lt;BR /&gt;
However, when the data is&lt;BR /&gt;
name1   8/27/10&lt;BR /&gt;
name1  9/15/10&lt;BR /&gt;
name2 8/22/10&lt;BR /&gt;
name2 10/22/10&lt;BR /&gt;
&lt;BR /&gt;
I need to obtain the first record of each group so I only get: &lt;BR /&gt;
name1   8/27/10&lt;BR /&gt;
name2 8/22/10&lt;BR /&gt;
&lt;BR /&gt;
I am not sure what you mean by ranking the variable. If I have to rank the date, then I have to do a proc sort first or after and that defeats the entire purpose.&lt;BR /&gt;
Why SAS does not include the TOP function is unknown but annoying.&lt;BR /&gt;
&lt;BR /&gt;
Sorry for the rants gents, just been one of those days..&lt;BR /&gt;
&lt;BR /&gt;
Lawrence</description>
      <pubDate>Wed, 23 Mar 2011 21:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35628#M8814</guid>
      <dc:creator>_LB</dc:creator>
      <dc:date>2011-03-23T21:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35629#M8815</link>
      <description>From what I read, consider that the TOP clause is not ANSI SQL standard, so it would be implemented various ways possibly, based on the DBMS system used.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 23 Mar 2011 22:23:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35629#M8815</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-03-23T22:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35630#M8816</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I'm confused as to why ksharp's solution doesnt work for you?  Adapted to your sample data, I think it is:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table want as&lt;BR /&gt;
&amp;nbsp;select name,date&lt;BR /&gt;
&amp;nbsp; from have&lt;BR /&gt;
&amp;nbsp;&amp;nbsp; group by name&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; having date eq min(date)&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;BR /&gt;
quit;&lt;BR /&gt;
&amp;nbsp;&lt;BR /&gt;
This would return multiple records if you have dups, but easy enough to dedup. &lt;BR /&gt;
&lt;BR /&gt;
If you want first 5 records per name, I would again agree with dbailey. Add a rank variable (could be done in a data step view, or perhaps a subquery with the undocumented monotonic() function), then use the rank to select records:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table want as&lt;BR /&gt;
&amp;nbsp;select name,date&lt;BR /&gt;
&amp;nbsp; from have&lt;BR /&gt;
&amp;nbsp;&amp;nbsp; group by name&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; having rank&amp;lt;(min(rank)+5)&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Not sure what you mean by PROC sort messing things up. Remember, the SQL engine may be sorting data in the background anyway. &lt;BR /&gt;
&lt;BR /&gt;
Above is all untested code, and i'm still learning SQL, so ymmv. &lt;BR /&gt;
&lt;BR /&gt;
Kind Regards,&lt;BR /&gt;
--Q.

Message was edited by: Quentin</description>
      <pubDate>Wed, 23 Mar 2011 23:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35630#M8816</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2011-03-23T23:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35631#M8817</link>
      <description>&lt;P&gt;If you are using the TOP syntax of T-SQL, then unless you include an order by statement, the rows are returned arbitrarily (see &lt;A href="http://msdn.microsoft.com/en-us/library/ms189463.aspx)" target="_blank"&gt;http://msdn.microsoft.com/en-us/library/ms189463.aspx)&lt;/A&gt;. If you are including an order by, that suggests you want the one record returned that is the min (or max) of date column.&lt;BR /&gt; &lt;BR /&gt; If this is representative of the data (tabA):&lt;/P&gt;
&lt;PRE&gt;NameVal NameDate OtherVar1 OtherVar2
name1 8/27/10 A F
name1 9/15/10 B G
name2 8/22/10 C H
name2 8/22/10 C1 H1
name2 10/22/10 D I&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	select
		a.nameval,
		a.namedate,
		a.othervar1,
		a.othervar2
	from tabA as A
		where a.NameDate = 
           (select min(NameDate) 
            from TabA where nameval = a.nameval);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt; This would return&lt;/P&gt;
&lt;PRE&gt;NameVal NameDate OtherVar1 OtherVar2
name1 8/27/10 A F
name2 8/22/10 C H
name2 8/22/10 C1 H1&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt; Note that this treats ties exactly like the top 1 statement would.&lt;BR /&gt; &lt;BR /&gt; If that isn't what you're trying to do, then perhaps some clarification would help.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 12:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35631#M8817</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2017-10-19T12:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35632#M8818</link>
      <description>quick point of clarification...you wouldn't need the group by using the ranked data.</description>
      <pubDate>Thu, 24 Mar 2011 02:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35632#M8818</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2011-03-24T02:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL equivalent of TOP</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35633#M8819</link>
      <description>DBailey;&lt;BR /&gt;
This helps immensely. Thank you.&lt;BR /&gt;
Lawrence</description>
      <pubDate>Thu, 24 Mar 2011 14:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-equivalent-of-TOP/m-p/35633#M8819</guid>
      <dc:creator>_LB</dc:creator>
      <dc:date>2011-03-24T14:57:58Z</dc:date>
    </item>
  </channel>
</rss>

