<?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: Why SQL &amp;quot;select into&amp;quot; needs separated by ' ' in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547379#M151688</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The "separated by ..." tells sql that you wants a &lt;STRONG&gt;list&lt;/STRONG&gt; of names.&lt;/P&gt;
&lt;P&gt;The list can be separated by any character given in a single quotes.&lt;/P&gt;
&lt;P&gt;Otherwise the names are overwritten and you probably get the last one only.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You get the value of the first row which is the smart thing as this way SAS doesn't have to process the whole table.&lt;/P&gt;
&lt;P&gt;I've just tested for two tables - one with only a few rows and one with 20M rows. SQL ... INTO :name run in no time for both tables&lt;/P&gt;
&lt;PRE&gt;NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds&lt;/PRE&gt;</description>
    <pubDate>Sat, 30 Mar 2019 03:24:03 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-03-30T03:24:03Z</dc:date>
    <item>
      <title>Why SQL "select into" needs separated by ' '</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547373#M151682</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I try to understand the logic.&lt;/P&gt;
&lt;P&gt;If without separated by, why SAS only return first value, at least it can return all values without space&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;HHCFX&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input abIc ID1 bxI4D b_ID2 xyzID_3; 
cards;
1 2 3 4 5
;run;

proc contents data=have out=varname;run;

proc sql;
select name into :droplist separated by ' ' from varname  where index(name,'ID')&amp;gt;0; quit;
%put &amp;amp;droplist;

*VS without separated by ' ';

proc sql;
select name into :droplist /*separated by ' '*/ from varname  where index(name,'ID')&amp;gt;0; quit;
%put &amp;amp;droplist;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Mar 2019 02:40:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547373#M151682</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2019-03-30T02:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Why SQL "select into" needs separated by ' '</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547375#M151684</link>
      <description>&lt;P&gt;The "separated by ..." tells sql that you wants a &lt;STRONG&gt;list&lt;/STRONG&gt; of names.&lt;/P&gt;
&lt;P&gt;The list can be separated by any character given in a single quotes.&lt;/P&gt;
&lt;P&gt;Otherwise the names are overwritten and you probably get the last one only.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 02:51:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547375#M151684</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-03-30T02:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Why SQL "select into" needs separated by ' '</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547376#M151685</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's just how it's implemented and the syntax works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively to a list of values you can also create individual macro variables per row - so you've got all the options at your fingertips.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select name into :namelist separated by ''
  from sashelp.class
  ;
quit;
%put &amp;amp;=namelist;

proc sql noprint;
  select name into :m_name_1 - :m_name_9999
  from sashelp.class
  ;
quit;

%macro printMvars();
  %do i=1 %to &amp;amp;sqlobs;
    %put m_name_&amp;amp;i= &amp;amp;&amp;amp;m_name_&amp;amp;i;
  %end;
%mend;
%printMvars()
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Mar 2019 02:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547376#M151685</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-03-30T02:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why SQL "select into" needs separated by ' '</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547378#M151687</link>
      <description>&lt;P&gt;Thanks for your explanation.&lt;/P&gt;
&lt;P&gt;It makes sense now.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 03:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547378#M151687</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2019-03-30T03:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Why SQL "select into" needs separated by ' '</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547379#M151688</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The "separated by ..." tells sql that you wants a &lt;STRONG&gt;list&lt;/STRONG&gt; of names.&lt;/P&gt;
&lt;P&gt;The list can be separated by any character given in a single quotes.&lt;/P&gt;
&lt;P&gt;Otherwise the names are overwritten and you probably get the last one only.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You get the value of the first row which is the smart thing as this way SAS doesn't have to process the whole table.&lt;/P&gt;
&lt;P&gt;I've just tested for two tables - one with only a few rows and one with 20M rows. SQL ... INTO :name run in no time for both tables&lt;/P&gt;
&lt;PRE&gt;NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Mar 2019 03:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547379#M151688</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-03-30T03:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Why SQL "select into" needs separated by ' '</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547390#M151693</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;, to your note&lt;/P&gt;
&lt;PRE&gt;You get the value of the first row which is the smart thing as this way SAS doesn't have to process the whole table.

I've just tested for two tables - one with only a few rows and one with 20M rows. SQL ... INTO :name run in no time for both tables&lt;/PRE&gt;
&lt;P&gt;selecting NAME by SQL - selects variable names from dictionary, no matter how many rows are in the dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 05:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-SQL-quot-select-into-quot-needs-separated-by/m-p/547390#M151693</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-03-30T05:48:18Z</dc:date>
    </item>
  </channel>
</rss>

