<?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 Macro variables and concatenation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variables-and-concatenation/m-p/27321#M4970</link>
    <description>Hi guys&lt;BR /&gt;
&lt;BR /&gt;
I want to extract logins from table to &lt;I&gt;userlist&lt;/I&gt; variable and substitute it to the &lt;I&gt;where&lt;/I&gt; clause. Here is a piece of code:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;%let in=work.MetaLogins;&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
   select Login&lt;BR /&gt;
   into :userlist separated by "','"&lt;BR /&gt;
   from &amp;amp;in;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
%let userlist = '&amp;amp;userlist';&lt;BR /&gt;
data logins;&lt;BR /&gt;
   set xml.Login;&lt;BR /&gt;
   where UserID in (&amp;amp;userlist);&lt;BR /&gt;
run;&lt;/B&gt;&lt;BR /&gt;
I am tired of that. Help me please to force it work.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
    <pubDate>Tue, 24 Jun 2008 10:10:22 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-06-24T10:10:22Z</dc:date>
    <item>
      <title>Macro variables and concatenation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variables-and-concatenation/m-p/27321#M4970</link>
      <description>Hi guys&lt;BR /&gt;
&lt;BR /&gt;
I want to extract logins from table to &lt;I&gt;userlist&lt;/I&gt; variable and substitute it to the &lt;I&gt;where&lt;/I&gt; clause. Here is a piece of code:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;%let in=work.MetaLogins;&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
   select Login&lt;BR /&gt;
   into :userlist separated by "','"&lt;BR /&gt;
   from &amp;amp;in;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
%let userlist = '&amp;amp;userlist';&lt;BR /&gt;
data logins;&lt;BR /&gt;
   set xml.Login;&lt;BR /&gt;
   where UserID in (&amp;amp;userlist);&lt;BR /&gt;
run;&lt;/B&gt;&lt;BR /&gt;
I am tired of that. Help me please to force it work.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Tue, 24 Jun 2008 10:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variables-and-concatenation/m-p/27321#M4970</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-24T10:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variables and concatenation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variables-and-concatenation/m-p/27322#M4971</link>
      <description>I think your problem is that LOGIN is a character variable, hence lacking quotes in the WHERE statement. When you add the external quotes in the %LET statement, the &amp;amp;userlist is not resolved, because simple quotes (') BLOCKS the macro resolution. Instead of adding them in the "SEPARATED BY" part, try this : combination of LEFT, TRIM (to remove trailing blanks) and QUOTE (adds quotes) functions in the SELECT clause, and only SEPARATED BY commas.&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let in=work.MetaLogins;&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
select QUOTE(LEFT(TRIM(Login)))&lt;BR /&gt;
into :userlist separated by ","&lt;BR /&gt;
from &amp;amp;in;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
data logins;&lt;BR /&gt;
set xml.Login;&lt;BR /&gt;
where UserID in (&amp;amp;userlist);&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Regards.&lt;BR /&gt;
Olivier</description>
      <pubDate>Tue, 24 Jun 2008 10:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variables-and-concatenation/m-p/27322#M4971</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-06-24T10:29:39Z</dc:date>
    </item>
  </channel>
</rss>

