<?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 Put all values of a variable into macro variable using proc sql into but it reads only first value in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Put-all-values-of-a-variable-into-macro-variable-using-proc-sql/m-p/914762#M44277</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am using the script below to put all the values into macro variables but it reads only the first value. Why?&lt;/P&gt;
&lt;P&gt;How to solve that Issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Vartable 3 first observations only

name1                            name2
ps.startDate,	pt.startDate = ps.startDate,
ps.endDate,	pt.endDate = ps.endDate,
ps.status,	pt.status = ps.status,

proc sql noprint ;
   select strip(name1), strip(name2)
      into :varlist1, :varlist2  
      from vartable;
Quit;
%put &amp;amp;=varlist1.;
%put &amp;amp;=varlist2.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Feb 2024 20:51:26 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2024-02-06T20:51:26Z</dc:date>
    <item>
      <title>Put all values of a variable into macro variable using proc sql into but it reads only first value</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Put-all-values-of-a-variable-into-macro-variable-using-proc-sql/m-p/914762#M44277</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am using the script below to put all the values into macro variables but it reads only the first value. Why?&lt;/P&gt;
&lt;P&gt;How to solve that Issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Vartable 3 first observations only

name1                            name2
ps.startDate,	pt.startDate = ps.startDate,
ps.endDate,	pt.endDate = ps.endDate,
ps.status,	pt.status = ps.status,

proc sql noprint ;
   select strip(name1), strip(name2)
      into :varlist1, :varlist2  
      from vartable;
Quit;
%put &amp;amp;=varlist1.;
%put &amp;amp;=varlist2.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Feb 2024 20:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Put-all-values-of-a-variable-into-macro-variable-using-proc-sql/m-p/914762#M44277</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-02-06T20:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Put all values of a variable into macro variable using proc sql into but it reads only first val</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Put-all-values-of-a-variable-into-macro-variable-using-proc-sql/m-p/914764#M44278</link>
      <description>&lt;P&gt;Because that is what you asked it to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can either concatenate the values into single macro variables by using the SEPARATED BY keyword. (PS Removing the leading spaces changes the meaning of the values. Just remove the trailing spaces.)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;
   select trim(name1), trim(name2)
      into :varlist1 separated by '|'
         , :varlist2 separated by '|'
      from vartable
;
%let nobs=&amp;amp;sqlobs;
quit;
%put &amp;amp;=varlist1;
%put &amp;amp;=varlist2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can create two SETS of variables with numeric suffixes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;
   select trim(name1), trim(name2)
      into :varlist1_1 -
         , :varlist2_1 -
      from vartable
;
%let nobs=&amp;amp;sqlobs;
quit;
%put &amp;amp;=varlist1_1  varlist1_&amp;amp;nobs=&amp;amp;&amp;amp;varlist1_&amp;amp;nobs;
%put &amp;amp;=varlist2_1  varlist2_&amp;amp;nobs=&amp;amp;&amp;amp;varlist2_&amp;amp;nobs;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Feb 2024 21:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Put-all-values-of-a-variable-into-macro-variable-using-proc-sql/m-p/914764#M44278</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-06T21:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Put all values of a variable into macro variable using proc sql into but it reads only first val</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Put-all-values-of-a-variable-into-macro-variable-using-proc-sql/m-p/914765#M44279</link>
      <description>&lt;P&gt;When you fail to add "separated by", SAS thinks you only want one value.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 21:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Put-all-values-of-a-variable-into-macro-variable-using-proc-sql/m-p/914765#M44279</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-02-06T21:22:52Z</dc:date>
    </item>
  </channel>
</rss>

