<?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 Can &amp;quot;let id2=1233 &amp;quot; be replaced with &amp;quot;let id2 in (&amp;quot;1233&amp;quot;,&amp;quot;1234&amp;quot;,&amp;quot;1245&amp;quot;) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-quot-let-id2-1233-quot-be-replaced-with-quot-let-id2-in-quot/m-p/363169#M85929</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET id1= a2222;
%let id2=b1222;


%macro wins(N) ;
DATA lib1.&amp;amp;id1. ;
set
  %do I= 1122 %To &amp;amp;N;
%if %sysfunc(exist(lib2. a&amp;amp;i)) 
%then %str( lib2. b_c_201&amp;amp;i ) ;
%end;
;
where	id2 ="&amp;amp;id2"

	
;


%mend wins; 
%wins(3322 );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I have used this quite well but my current task is that id2 has three values instead of one. My question is, should I remove this macro, and type each value instead, such as: where id2 in ("1233","1234","1245")&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2017 17:39:01 GMT</pubDate>
    <dc:creator>Bal23</dc:creator>
    <dc:date>2017-05-31T17:39:01Z</dc:date>
    <item>
      <title>Can "let id2=1233 " be replaced with "let id2 in ("1233","1234","1245")</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-quot-let-id2-1233-quot-be-replaced-with-quot-let-id2-in-quot/m-p/363169#M85929</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET id1= a2222;
%let id2=b1222;


%macro wins(N) ;
DATA lib1.&amp;amp;id1. ;
set
  %do I= 1122 %To &amp;amp;N;
%if %sysfunc(exist(lib2. a&amp;amp;i)) 
%then %str( lib2. b_c_201&amp;amp;i ) ;
%end;
;
where	id2 ="&amp;amp;id2"

	
;


%mend wins; 
%wins(3322 );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I have used this quite well but my current task is that id2 has three values instead of one. My question is, should I remove this macro, and type each value instead, such as: where id2 in ("1233","1234","1245")&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 17:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-quot-let-id2-1233-quot-be-replaced-with-quot-let-id2-in-quot/m-p/363169#M85929</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2017-05-31T17:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can "let id2=1233 " be replaced with "let id2 in ("1233","1234&amp;quo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-quot-let-id2-1233-quot-be-replaced-with-quot-let-id2-in-quot/m-p/363176#M85934</link>
      <description>&lt;P&gt;You could use:&lt;/P&gt;
&lt;PRE&gt;%let id2='James','Jane','John';
data want;
  set sashelp.class (where=(name in (&amp;amp;id2.)));
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 17:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-quot-let-id2-1233-quot-be-replaced-with-quot-let-id2-in-quot/m-p/363176#M85934</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-31T17:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can "let id2=1233 " be replaced with "let id2 in ("1233","1234&amp;amp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-quot-let-id2-1233-quot-be-replaced-with-quot-let-id2-in-quot/m-p/363179#M85935</link>
      <description>&lt;P&gt;To expand on the correct answer by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;, don't mix the data which can be variable (the values that &amp;amp;id2 takes on) with the data step code which is constant.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the only thing that is varying is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"1233","1234","1245"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so that's all you need to include in the macro variable. The part which reads&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where id2 in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is constant so it should not be put into a macro variable.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 18:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-quot-let-id2-1233-quot-be-replaced-with-quot-let-id2-in-quot/m-p/363179#M85935</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-05-31T18:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can "let id2=1233 " be replaced with "let id2 in ("1233","1234&amp;quo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-quot-let-id2-1233-quot-be-replaced-with-quot-let-id2-in-quot/m-p/363187#M85939</link>
      <description>&lt;P&gt;You are already working in a macro, so you can use a %DO loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as the values inside the IN operator are consecutive, you can use this construct to get your WHERE statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;where id2 in (&lt;/FONT&gt;&amp;nbsp;&amp;nbsp; %do i=&amp;amp;id2 %to &amp;amp;id2 + 2;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color="#ff0000"&gt;"&amp;amp;i"&lt;/FONT&gt;&amp;nbsp; %end;&amp;nbsp; &lt;FONT color="#ff0000"&gt;) ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;The pieces in red become your WHERE statement.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 19:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-quot-let-id2-1233-quot-be-replaced-with-quot-let-id2-in-quot/m-p/363187#M85939</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-31T19:04:53Z</dc:date>
    </item>
  </channel>
</rss>

