<?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: Need to condense a PROC SQL into one step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125667#M25656</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom, I think the question is inspired by the fact that many versions of SQL do not support auto remerge.&amp;nbsp; - PG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. See SQL Procedure Enhancements &lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm#p0corah7t43hy7n1r7efplde5c8z.htm" title="http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm#p0corah7t43hy7n1r7efplde5c8z.htm"&gt;SAS(R) 9.3 SQL Procedure User's Guide&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Jul 2013 02:16:28 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2013-07-03T02:16:28Z</dc:date>
    <item>
      <title>Need to condense a PROC SQL into one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125663#M25652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two data sets test1 and test2 as such:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Test1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Var1&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Test2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Var1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Pack&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rank&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aaa&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1a&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1b&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aaa&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2a&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2b&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ccc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to end up with a data set test3 as such using a single PROC SQL step. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Test3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Var1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Pack&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rank&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1b&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ccc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can do it in two PROC SQL steps using a MAX function and then joining back, but I believe this can be done with "windowing" in just one step but not sure how to exactly? &lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 22:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125663#M25652</guid>
      <dc:creator>SASguyCO</dc:creator>
      <dc:date>2013-07-02T22:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Need to condense a PROC SQL into one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125664#M25653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know if SAS supports windowing. There are some common alternatives here, or below, but both use two passes of the data anyways. &lt;/P&gt;&lt;P&gt;Can you do a data step.&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="https://www.simple-talk.com/sql/learn-sql-server/window-functions-in-sql-server/" title="https://www.simple-talk.com/sql/learn-sql-server/window-functions-in-sql-server/"&gt;https://www.simple-talk.com/sql/learn-sql-server/window-functions-in-sql-server/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; Test1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;input&lt;/SPAN&gt; Var1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;cards&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;2&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&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="font-size: 12pt;"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; Test2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;input&lt;/SPAN&gt; Var1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Pack $&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rank $;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;cards&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aaa&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1a&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1b&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aaa&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2a&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2b&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ccc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2c&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;run;&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'; color: #011993;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;create&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;table&lt;SPAN style="color: #000000;"&gt; want &lt;/SPAN&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;select&lt;SPAN style="color: #000000;"&gt; * &lt;/SPAN&gt;from&lt;SPAN style="color: #000000;"&gt; test2&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;where&lt;/SPAN&gt; var1 &lt;SPAN style="color: #0433ff;"&gt;in&lt;/SPAN&gt; (&lt;SPAN style="color: #0433ff;"&gt;select&lt;/SPAN&gt; var1 &lt;SPAN style="color: #0433ff;"&gt;from&lt;/SPAN&gt; test1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;group&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;by&lt;SPAN style="color: #000000;"&gt; var1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;having rank=max(rank)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&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; font-size: 12pt;"&gt;&lt;BR /&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; font-size: 12pt;"&gt;OR &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="color: #000000; font-size: 12pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;create&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;table&lt;SPAN style="color: #000000;"&gt; want &lt;/SPAN&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;select&lt;/SPAN&gt; * &lt;SPAN style="color: #0433ff;"&gt;from&lt;/SPAN&gt; test2 a&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;right&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;join&lt;/SPAN&gt; test1 b&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;on&lt;/SPAN&gt; a.var1=b.var1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;group&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;by&lt;/SPAN&gt; a.var1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;having rank=max(rank)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 23:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125664#M25653</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-07-02T23:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need to condense a PROC SQL into one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125665#M25654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza, that last query would work better as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table want as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select b.var1, pack, rank &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; test2 a right join &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; test1 b on a.var1=b.var1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;group by b.var1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;having rank=max(rank);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 00:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125665#M25654</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-07-03T00:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need to condense a PROC SQL into one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125666#M25655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do not understand the question.&amp;nbsp; Reading the link posted by Reeza about "windowing" it seem to just be the ability to include values that are neither group variables or aggregate functions in the variable list.&amp;nbsp; SAS already allows this and it does not require any additional syntax.&amp;nbsp; Now if you want to apply a "window" that is different than that implied by the values of your group by variables then you will need to add additional steps or nested queries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But your example to me just looks like a simple having clause applied to the sinlge source file TEST2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from test2 group by var1 having rank = max(rank) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from test2 group by var1 having pack = max(pack) ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 01:12:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125666#M25655</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-07-03T01:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need to condense a PROC SQL into one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125667#M25656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom, I think the question is inspired by the fact that many versions of SQL do not support auto remerge.&amp;nbsp; - PG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. See SQL Procedure Enhancements &lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm#p0corah7t43hy7n1r7efplde5c8z.htm" title="http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm#p0corah7t43hy7n1r7efplde5c8z.htm"&gt;SAS(R) 9.3 SQL Procedure User's Guide&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 02:16:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125667#M25656</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-07-03T02:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need to condense a PROC SQL into one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125668#M25657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the replies all.&amp;nbsp; I asked about windowing because I was told by another colleague that this is what I needed to do via SQL syntax.&amp;nbsp; He actually created the syntax for me in SQL but I can't convert it to SAS SQL with the functions he has used.&amp;nbsp; It's all good though.&amp;nbsp; I appreciate the help, but think I'm going to need to go another direction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 03:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125668#M25657</guid>
      <dc:creator>SASguyCO</dc:creator>
      <dc:date>2013-07-03T03:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need to condense a PROC SQL into one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125669#M25658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have a real example of a query that you cannot figure out how to execute then start a new thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is especially complex to do in SQL it is probably easier to just do with a DATA STEP or their might even be a PROC that can do it for you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 03:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125669#M25658</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-07-03T03:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Need to condense a PROC SQL into one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125670#M25659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;Hi,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;How about this one...&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; one;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; var1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;cards4&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black;"&gt;2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black;"&gt;3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;;;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; two;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; var1 pack $ rank $;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;cards4&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black;"&gt;1 aaa 1a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black;"&gt;1 bbb 1b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black;"&gt;2 aaa 2a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black;"&gt;2 bbb 2b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black;"&gt;2 ccc 2c&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black;"&gt;3 aaa 3a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black;"&gt;3 bbb 3b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;;;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; count(distinct *) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; :obs&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; one;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;reset&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;outobs&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; = &amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: teal;"&gt;obs.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; both &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; a.var1,pack,rank&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; one &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; a &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; two &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;on&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; a.var1 = b.var1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;order&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; pack &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;desc&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;-Urvish&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 06:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125670#M25659</guid>
      <dc:creator>UrvishShah</dc:creator>
      <dc:date>2013-07-03T06:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need to condense a PROC SQL into one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125671#M25660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;STRONG style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link active_link" data-avatarid="1090" data-externalid="" data-presence="null" data-userid="714827" data-username="SASguyCO" href="https://communities.sas.com/people/SASguyCO" id="jive-71482773775234565853803" style="padding: 0 3px 0 0; font-weight: inherit; font-style: inherit; font-size: 1.1em; font-family: inherit; color: #0e66ba; text-decoration: underline;"&gt;SASguyCO&lt;/A&gt;&lt;/STRONG&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps I don't understand your question but, why are you so fixated on using SQL to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would have thought that a couple of sorts and a merge by VAR1 using IF A AND LAST.VAR1 would have the desired effect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;SM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jul 2013 13:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125671#M25660</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2013-07-08T13:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need to condense a PROC SQL into one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125672#M25661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes a data step is fine too, but it's okay as I've gone about my solution another way.&amp;nbsp; Appreciate everyone's help though!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jul 2013 15:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125672#M25661</guid>
      <dc:creator>SASguyCO</dc:creator>
      <dc:date>2013-07-08T15:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need to condense a PROC SQL into one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125673#M25662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does this give you the desired result?&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt; create table test3 as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select a.*&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,max(b.pack) as Pack&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,max(b.rank)&amp;nbsp; as Rank&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from test1 a left outer join test2 b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; on a.var1=b.var1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; group by a.var1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by a.var1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jul 2013 21:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-condense-a-PROC-SQL-into-one-step/m-p/125673#M25662</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2013-07-08T21:12:02Z</dc:date>
    </item>
  </channel>
</rss>

