<?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: USING :INTO in SUBQUERIES in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/USING-INTO-in-SUBQUERIES/m-p/392366#M94396</link>
    <description>&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;says, no.&lt;/P&gt;
&lt;P&gt;But the "fix" is insted of subquery create a separate query that generates just the macro variables you attempt from the subquery. But that may not be needed at all.&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
   select distinct names into :names1-:names9999
   from sample
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do not 9999 distinct names on the names1-namesXXX are created.&lt;/P&gt;
&lt;P&gt;The automatic SAS macro variable &amp;amp;sqlobs will have the count of returned items in the last previous query.&lt;/P&gt;
&lt;P&gt;So&lt;/P&gt;
&lt;P&gt;%let NameCount = &amp;amp;sqlobs;&lt;/P&gt;
&lt;P&gt;immediately after the Proc SQL will capture that count.&lt;/P&gt;
&lt;P&gt;If you suspect you need more than 9999 macro variables (a real bad sign IMHO) increase the count.&lt;/P&gt;</description>
    <pubDate>Thu, 31 Aug 2017 20:34:12 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-08-31T20:34:12Z</dc:date>
    <item>
      <title>USING :INTO in SUBQUERIES</title>
      <link>https://communities.sas.com/t5/SAS-Programming/USING-INTO-in-SUBQUERIES/m-p/392310#M94374</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a quick question can we create macro variables using :INTO clause in subqueries&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select distinct names into :names1-:names&amp;amp;total from&lt;BR /&gt;(select names,Count(distinct names) into :total &amp;nbsp;from sample)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can we use :into in &amp;nbsp;a subquery as shown above&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 18:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/USING-INTO-in-SUBQUERIES/m-p/392310#M94374</guid>
      <dc:creator>User12</dc:creator>
      <dc:date>2017-08-31T18:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: USING :INTO in SUBQUERIES</title>
      <link>https://communities.sas.com/t5/SAS-Programming/USING-INTO-in-SUBQUERIES/m-p/392312#M94375</link>
      <description>&lt;P&gt;The answer is NO.&lt;/P&gt;&lt;P&gt;RTM--&amp;gt;&lt;/P&gt;&lt;DIV class="xis-paragraph"&gt;The INTO clause for the SELECT statement can assign the result of a calculation or the value of a data column (variable) to a macro variable. If the macro variable does not exist, INTO creates it. You can check the PROC SQL macro variable SQLOBS to see the number of rows (observations) produced by a SELECT statement.&lt;/DIV&gt;&lt;DIV class="xis-paragraph"&gt;&lt;STRONG&gt;&lt;EM&gt;The INTO clause can be used only in the outer query of a SELECT statement and not in a subquery.&lt;/EM&gt;&lt;/STRONG&gt; The INTO clause cannot be used when you are creating a table (CREATE TABLE) or a view (CREATE VIEW).&lt;/DIV&gt;&lt;DIV class="xis-paragraph"&gt;Macro variables created with INTO follow the scoping rules for the %LET statement.&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="xis-paragraph"&gt;Values assigned by the INTO clause use the BEST8. format.&lt;/DIV&gt;</description>
      <pubDate>Thu, 31 Aug 2017 18:19:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/USING-INTO-in-SUBQUERIES/m-p/392312#M94375</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-08-31T18:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: USING :INTO in SUBQUERIES</title>
      <link>https://communities.sas.com/t5/SAS-Programming/USING-INTO-in-SUBQUERIES/m-p/392366#M94396</link>
      <description>&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;says, no.&lt;/P&gt;
&lt;P&gt;But the "fix" is insted of subquery create a separate query that generates just the macro variables you attempt from the subquery. But that may not be needed at all.&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
   select distinct names into :names1-:names9999
   from sample
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do not 9999 distinct names on the names1-namesXXX are created.&lt;/P&gt;
&lt;P&gt;The automatic SAS macro variable &amp;amp;sqlobs will have the count of returned items in the last previous query.&lt;/P&gt;
&lt;P&gt;So&lt;/P&gt;
&lt;P&gt;%let NameCount = &amp;amp;sqlobs;&lt;/P&gt;
&lt;P&gt;immediately after the Proc SQL will capture that count.&lt;/P&gt;
&lt;P&gt;If you suspect you need more than 9999 macro variables (a real bad sign IMHO) increase the count.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 20:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/USING-INTO-in-SUBQUERIES/m-p/392366#M94396</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-31T20:34:12Z</dc:date>
    </item>
  </channel>
</rss>

