<?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 list issue - Proc SQL seperate by ' ' ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511140#M137542</link>
    <description>&lt;P&gt;Hi all:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created a macro list by Proc SQL.&amp;nbsp;&amp;nbsp; However, I found there are space between the ID and could not be recognized in Where statement.&amp;nbsp; For example, ID is 'DCT00025', 'DEY00056', 'DWR00047', etc.&amp;nbsp; After the macro, it became ''DCT00025 &amp;nbsp;', 'DEY00056 &amp;nbsp;', 'DWR00047 '.&amp;nbsp;&amp;nbsp; Please advice how to solve this problem.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select ID into : Unmatchlist separated by " ',' " from Unmatch;
quit;
 
%put &amp;amp;Unmatchlist;

data Want;
	set Test (keep = ID SITE DATE);
	where ID in ('&amp;amp;Unmatchlist');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I got my macro Unmatch list like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1037 %put &amp;amp;Unmatchlist;&lt;/P&gt;
&lt;P&gt;DCT00025&amp;nbsp; ', '&amp;nbsp; DEY00056&amp;nbsp; ', '&amp;nbsp; DWR00047&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which makes them unrecognized in the where statement.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Nov 2018 19:15:59 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2018-11-07T19:15:59Z</dc:date>
    <item>
      <title>Macro list issue - Proc SQL seperate by ' ' ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511140#M137542</link>
      <description>&lt;P&gt;Hi all:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created a macro list by Proc SQL.&amp;nbsp;&amp;nbsp; However, I found there are space between the ID and could not be recognized in Where statement.&amp;nbsp; For example, ID is 'DCT00025', 'DEY00056', 'DWR00047', etc.&amp;nbsp; After the macro, it became ''DCT00025 &amp;nbsp;', 'DEY00056 &amp;nbsp;', 'DWR00047 '.&amp;nbsp;&amp;nbsp; Please advice how to solve this problem.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select ID into : Unmatchlist separated by " ',' " from Unmatch;
quit;
 
%put &amp;amp;Unmatchlist;

data Want;
	set Test (keep = ID SITE DATE);
	where ID in ('&amp;amp;Unmatchlist');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I got my macro Unmatch list like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1037 %put &amp;amp;Unmatchlist;&lt;/P&gt;
&lt;P&gt;DCT00025&amp;nbsp; ', '&amp;nbsp; DEY00056&amp;nbsp; ', '&amp;nbsp; DWR00047&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which makes them unrecognized in the where statement.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 19:15:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511140#M137542</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2018-11-07T19:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macro list issue - Proc SQL seperate by ' ' ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511145#M137545</link>
      <description>&lt;P&gt;Do it in one SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select id, site, date
from test
where id in (select id from unmatch);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Nov 2018 19:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511145#M137545</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-07T19:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro list issue - Proc SQL seperate by ' ' ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511148#M137546</link>
      <description>Select ID format= $quote100. Into unmatchList separated by    ', ' &lt;BR /&gt;From unmatch&lt;BR /&gt;&lt;BR /&gt;The $quote format applies the trimming</description>
      <pubDate>Wed, 07 Nov 2018 19:24:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511148#M137546</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-07T19:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro list issue - Proc SQL seperate by ' ' ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511150#M137547</link>
      <description>I should add the usage of the macro variable needs no quotes:&lt;BR /&gt;Where ID in( &amp;amp;unmatchList)</description>
      <pubDate>Wed, 07 Nov 2018 19:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511150#M137547</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-07T19:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro list issue - Proc SQL seperate by ' ' ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511156#M137548</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data unmatch;
input id $10.;
cards;
DCT00025
DEY00056
DWR00047
;
proc sql noprint;
	select quote(strip(ID)) into : Unmatchlist  separated by  ','   from Unmatch;
quit;
 
%put &amp;amp;Unmatchlist;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; Want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; Test &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;keep&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt; SITE &lt;SPAN class="token function"&gt;DATE&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	&lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;&amp;amp;Unmatchlist&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Nov 2018 19:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511156#M137548</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-07T19:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: Macro list issue - Proc SQL seperate by ' ' ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511173#M137552</link>
      <description>Storing leading blanks seem unnatural  to me, in the SAS environment. &lt;BR /&gt;Hence I never think of using STRIP() function.&lt;BR /&gt;And I should test whether the $quote format performs STRIP or TRIM in my SQL code above</description>
      <pubDate>Wed, 07 Nov 2018 19:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511173#M137552</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-07T19:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro list issue - Proc SQL seperate by ' ' ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511197#M137554</link>
      <description>&lt;P&gt;Hi KurtBremser:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the Q is answered more closed by Novinosrin, although your code is definitely more directly and simple.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 20:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-list-issue-Proc-SQL-seperate-by/m-p/511197#M137554</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2018-11-07T20:58:59Z</dc:date>
    </item>
  </channel>
</rss>

