<?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 Proc sql TOP equivalent in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-TOP-equivalent/m-p/364952#M86624</link>
    <description>&lt;P&gt;I have the following code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UPDATE TEMP&lt;/P&gt;&lt;P&gt;SET CUST_NATIONALITY=(SELECT CUST_NATIONALITY&lt;/P&gt;&lt;P&gt;FROM (SELECT CUST_NATIONALITY, COUNT(CUST_NATIONALITY) AS FREQ&lt;/P&gt;&lt;P&gt;FROM MIP_LIB.REATIL_PORTFOLIO_NEW&lt;/P&gt;&lt;P&gt;GROUP BY CUST_NATIONALITY)&lt;/P&gt;&lt;P&gt;HAVING FREQ=MAX(FREQ))&lt;/P&gt;&lt;P&gt;WHERE CUST_NATIONALITY IS NULL;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The subquery is returning more than one value. Any one of the value will do for me. Can anyone suggest how to do this with the minimum change made, as I have several such queries throughout my project.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jun 2017 12:49:36 GMT</pubDate>
    <dc:creator>Bipasha</dc:creator>
    <dc:date>2017-06-07T12:49:36Z</dc:date>
    <item>
      <title>Proc sql TOP equivalent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-TOP-equivalent/m-p/364952#M86624</link>
      <description>&lt;P&gt;I have the following code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UPDATE TEMP&lt;/P&gt;&lt;P&gt;SET CUST_NATIONALITY=(SELECT CUST_NATIONALITY&lt;/P&gt;&lt;P&gt;FROM (SELECT CUST_NATIONALITY, COUNT(CUST_NATIONALITY) AS FREQ&lt;/P&gt;&lt;P&gt;FROM MIP_LIB.REATIL_PORTFOLIO_NEW&lt;/P&gt;&lt;P&gt;GROUP BY CUST_NATIONALITY)&lt;/P&gt;&lt;P&gt;HAVING FREQ=MAX(FREQ))&lt;/P&gt;&lt;P&gt;WHERE CUST_NATIONALITY IS NULL;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The subquery is returning more than one value. Any one of the value will do for me. Can anyone suggest how to do this with the minimum change made, as I have several such queries throughout my project.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 12:49:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-TOP-equivalent/m-p/364952#M86624</guid>
      <dc:creator>Bipasha</dc:creator>
      <dc:date>2017-06-07T12:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql TOP equivalent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-TOP-equivalent/m-p/364973#M86636</link>
      <description>&lt;P&gt;I think, simplest is to make one record table and then update. Like something below&lt;/P&gt;
&lt;PRE&gt;proc sql outobs= 1;
create table temp_stage as

SELECT CUST_NATIONALITY

FROM (SELECT CUST_NATIONALITY, COUNT(CUST_NATIONALITY) AS FREQ

FROM MIP_LIB.REATIL_PORTFOLIO_NEW

GROUP BY CUST_NATIONALITY)

HAVING FREQ=MAX(FREQ))

WHERE CUST_NATIONALITY IS NULL;

quit;


proc sql; 

UPDATE TEMP

SET CUST_NATIONALITY=(select cust_nationality from temp_stage);;

quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 13:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-TOP-equivalent/m-p/364973#M86636</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-07T13:32:36Z</dc:date>
    </item>
  </channel>
</rss>

