<?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: Query to return 1 instance for each id in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80310#M7865</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To carry this out with a data step look into reading the data &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;by&lt;/STRONG&gt;&lt;/SPAN&gt; Client_ID and using the &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;retain&lt;/STRONG&gt;&lt;/SPAN&gt; statement to hold values of the Store and Purchases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/SPAN&gt; this is the highest value for Purchases in this by group &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;then&lt;/STRONG&gt;&lt;/SPAN&gt; save the values of Store and Purchases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the end of the &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;by&lt;/STRONG&gt;&lt;/SPAN&gt; group you can &lt;STRONG style="font-family: 'courier new', courier;"&gt;output&lt;/STRONG&gt; the Client_ID and the Store and Purchases values you have retained to your output &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that gives you some &lt;STRONG&gt;clues&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jul 2013 11:58:07 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2013-07-16T11:58:07Z</dc:date>
    <item>
      <title>Query to return 1 instance for each id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80309#M7864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;Hey guys, thanks for the time,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;So not to confuse you, i will try to explain my issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;I have a table that contains information about clients and i would like to choose the store with maximum purchases for each client&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: justify;"&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 335px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="21" style="text-align: center;" width="83"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;Client_ID&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl63" width="125"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;Store&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl63" width="127"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;Purchases&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl70" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;1&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl71"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl72"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;2&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;1&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl78"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl75" height="21"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;1&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl76"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;4&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl77"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl70" height="20" style="border-top: none;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;2&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl71" style="border-top: none;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;2&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;7&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl78"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl75" height="21"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;2&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl76"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;6&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl77"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl70" height="20" style="border-top: none;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl71" style="border-top: none;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl78"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl74"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;2&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl75" height="21"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl76"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;4&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl77"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;1&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl70" height="20" style="border-top: none;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;4&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl71" style="border-top: none;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;2&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;4&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;7&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl78"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl75" height="21"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;4&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl76"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;6&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl77"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;1&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl70" height="20" style="border-top: none;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl71" style="border-top: none;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top: none;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;2&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl78"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl75" height="21"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl76"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;4&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl77"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;1&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;6&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl66"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;1&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;6&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;7&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl66"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;2&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="21"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;6&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;6&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl78"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl70" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;7&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl71"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl72"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;4&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;7&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl74"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl75" height="21"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;7&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl76"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;4&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl78"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;8&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;5&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl66"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;2&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;8&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;7&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl78"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl67" height="21" style="text-align: justify;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;8&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl68" style="text-align: justify;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;6&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl69" style="text-align: justify;"&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;1&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;So, for the example above, i need to choose the store with the maximum purchases for my client.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;I don't think i can use "top with ties" which seems to be the solution if i were using T-SQL but since my data are stored on SAS EG, i cannot do so.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;Ideas, please?!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 11:33:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80309#M7864</guid>
      <dc:creator>M_A_C</dc:creator>
      <dc:date>2013-07-16T11:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Query to return 1 instance for each id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80310#M7865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To carry this out with a data step look into reading the data &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;by&lt;/STRONG&gt;&lt;/SPAN&gt; Client_ID and using the &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;retain&lt;/STRONG&gt;&lt;/SPAN&gt; statement to hold values of the Store and Purchases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/SPAN&gt; this is the highest value for Purchases in this by group &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;then&lt;/STRONG&gt;&lt;/SPAN&gt; save the values of Store and Purchases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the end of the &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;by&lt;/STRONG&gt;&lt;/SPAN&gt; group you can &lt;STRONG style="font-family: 'courier new', courier;"&gt;output&lt;/STRONG&gt; the Client_ID and the Store and Purchases values you have retained to your output &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that gives you some &lt;STRONG&gt;clues&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 11:58:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80310#M7865</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2013-07-16T11:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: Query to return 1 instance for each id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80311#M7866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;select &lt;SPAN style="font-family: georgia, palatino;"&gt;Client_ID,&lt;SPAN style="font-family: georgia, palatino;"&gt;Store,max(&lt;SPAN style="font-family: georgia, palatino;"&gt;Purchases)as MaxPurchases&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;from yourtable&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;group by &lt;SPAN style="font-family: georgia, palatino;"&gt;Client_ID,&lt;SPAN style="font-family: georgia, palatino;"&gt;Store;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino;"&gt;Fred&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 11:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80311#M7866</guid>
      <dc:creator>fred_major</dc:creator>
      <dc:date>2013-07-16T11:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Query to return 1 instance for each id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80312#M7867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fred's solution will return one record for each client_id, store pair and not one record per client_id. I believe you wanted a single store returned per client so here are 2 solutions viable. The sort+data step will return only a single record. The proc sql will return all stores that share the same maximum purchase assuming you would want more than one record if there was a tie for the maximum&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input clientid store purchases;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;1 1 100&lt;/P&gt;&lt;P&gt;1 2 155&lt;/P&gt;&lt;P&gt;1 3 155&lt;/P&gt;&lt;P&gt;2 3 222&lt;/P&gt;&lt;P&gt;2 2 234&lt;/P&gt;&lt;P&gt;2 4 111&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;/* Soln 1, single return even when there are ties */&lt;/P&gt;&lt;P&gt;proc sort data=temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by clientid purchases;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by clientid;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last.clientid then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/* end of soln1 */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* soln2, multiple returns when ties occur */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select clientid, store, purchases&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select clientid, store, purchases, max(purchases) as maxpurchases&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from temp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by clientid&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where purchases=maxpurchases;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 12:08:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80312#M7867</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-07-16T12:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Query to return 1 instance for each id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80313#M7868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Vince, &lt;/P&gt;&lt;P&gt;Soln1 was exactly what i was looking for.&lt;/P&gt;&lt;P&gt;Gotta automate a whole process to get to the study of product affinity so has to start with this &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;Thanks again mate !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 12:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80313#M7868</guid>
      <dc:creator>M_A_C</dc:creator>
      <dc:date>2013-07-16T12:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Query to return 1 instance for each id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80314#M7869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Amir, gave me clues as you said &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; vince ws kind enough to give me the solution lol&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 12:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80314#M7869</guid>
      <dc:creator>M_A_C</dc:creator>
      <dc:date>2013-07-16T12:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Query to return 1 instance for each id</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80315#M7870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks fred for the response.&lt;/P&gt;&lt;P&gt;The script you wrote does return a result for each (Client_Id, Store) Combination which isn't what i am looking for but the answer vince gave was just it. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 12:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Query-to-return-1-instance-for-each-id/m-p/80315#M7870</guid>
      <dc:creator>M_A_C</dc:creator>
      <dc:date>2013-07-16T12:32:13Z</dc:date>
    </item>
  </channel>
</rss>

