<?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: compare a macro variable with macro variable list in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358640#M84304</link>
    <description>&lt;P&gt;I want to use this as&amp;nbsp;&lt;/P&gt;&lt;P&gt;if &amp;amp;va1 contains value in &amp;amp;var2 then do;&lt;/P&gt;&lt;P&gt;-----------------------&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;else do;&lt;/P&gt;&lt;P&gt;------------------------------------&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can u tell me how can i compare in an if condition ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 May 2017 04:51:24 GMT</pubDate>
    <dc:creator>shubham13</dc:creator>
    <dc:date>2017-05-15T04:51:24Z</dc:date>
    <item>
      <title>compare a macro variable with macro variable list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358638#M84302</link>
      <description>&lt;P&gt;%let var1=12MAY2017;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql ;&lt;BR /&gt;select H_date into:var2 seperated by ',' from Holiday_list ;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var2 will contain values from 01JAN2017 to 31DEC2017 (holiday list for 2017)&lt;/P&gt;&lt;P&gt;how to see if var1 contains values in var2 ??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 04:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358638#M84302</guid>
      <dc:creator>shubham13</dc:creator>
      <dc:date>2017-05-15T04:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: compare a macro variable with macro variable list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358639#M84303</link>
      <description>&lt;P&gt;Use %do%while loop witth %scan function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's very easy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 04:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358639#M84303</guid>
      <dc:creator>Saurabh13</dc:creator>
      <dc:date>2017-05-15T04:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: compare a macro variable with macro variable list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358640#M84304</link>
      <description>&lt;P&gt;I want to use this as&amp;nbsp;&lt;/P&gt;&lt;P&gt;if &amp;amp;va1 contains value in &amp;amp;var2 then do;&lt;/P&gt;&lt;P&gt;-----------------------&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;else do;&lt;/P&gt;&lt;P&gt;------------------------------------&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can u tell me how can i compare in an if condition ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 04:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358640#M84304</guid>
      <dc:creator>shubham13</dc:creator>
      <dc:date>2017-05-15T04:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: compare a macro variable with macro variable list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358643#M84305</link>
      <description>&lt;P&gt;Try next code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; retain holydays "&amp;amp;var2"; &amp;nbsp;/* the list */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if &amp;nbsp;index(holydays,"&amp;amp;var1") then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;---- holyday action ----&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; else do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ------&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have edited the code to repair some typos.&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 10:08:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358643#M84305</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-05-15T10:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: compare a macro variable with macro variable list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358645#M84306</link>
      <description>&lt;P&gt;Using SYSFUNC will allow you to use the standard SAS FINDW or INDEXW functions.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 05:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358645#M84306</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-15T05:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: compare a macro variable with macro variable list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358647#M84307</link>
      <description>&lt;P&gt;Flag will be 0 if not in list, integer otherwise:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let Flag=%Index("&amp;amp;var2",&amp;amp;var1.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;.. and you have a typo in "separated".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 05:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358647#M84307</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2017-05-15T05:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: compare a macro variable with macro variable list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358660#M84308</link>
      <description>&lt;P&gt;Why use a macro variable list at all?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let var1=12MAY2017;
 
%let flag = 0;

data _null_;
set Holiday_list;
if var2 = "&amp;amp;var1"d then call symput('flag','1');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Assuming that var2 in Holiday_list is a SAS date variable (numeric with date format assigned)&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 06:37:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358660#M84308</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-15T06:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: compare a macro variable with macro variable list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358709#M84314</link>
      <description>&lt;P&gt;Shubham,&lt;/P&gt;&lt;P&gt;So far you got a lot of good hints, but not a complete solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is quite simple, though:&lt;/P&gt;&lt;P&gt;%sysfunc(indexw(&amp;amp;var2,&amp;amp;var1)) will give you a positive number if &amp;amp;VAR1 is present as a word in &amp;amp;VAR2, otherwise you will get 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you can use it in a macro like&lt;/P&gt;&lt;PRE&gt;%if &lt;SPAN&gt;%sysfunc(indexw(&amp;amp;var2,&amp;amp;var1)) %then...&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Søren&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 11:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358709#M84314</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2017-05-15T11:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: compare a macro variable with macro variable list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358712#M84316</link>
      <description>&lt;P&gt;You can use the %inm macro to replicate the functionality of the SAS command IN as a macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macro is explained here, it's pretty simple&lt;/P&gt;
&lt;P&gt;&lt;A href="https://groups.google.com/forum/#!topic/comp.soft-sys.sas/fWcSDgg11tE" target="_blank"&gt;https://groups.google.com/forum/#!topic/comp.soft-sys.sas/fWcSDgg11tE&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 12:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358712#M84316</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-05-15T12:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: compare a macro variable with macro variable list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358716#M84319</link>
      <description>&lt;PRE&gt;
You want put it in Data Step or A Macro ?


%let var1=12MAY2017;
 
data holiday_list;
 do h_date='01jan2017'd to '01jun2017'd ; 
  output;
 end;
run;
proc sql noprint;
select put(H_date,date9.) into:var2 separated by ',' from Holiday_list ;
quit;

data x;
 set holiday_list;
 if findw(symget('var2'),"&amp;amp;var1") then put 'found'; 
  else put 'not found';
run;


&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 May 2017 12:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358716#M84319</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-15T12:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: compare a macro variable with macro variable list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358724#M84322</link>
      <description>&lt;P&gt;thank you sir, it worked !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2017 12:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-a-macro-variable-with-macro-variable-list/m-p/358724#M84322</guid>
      <dc:creator>shubham13</dc:creator>
      <dc:date>2017-05-15T12:35:18Z</dc:date>
    </item>
  </channel>
</rss>

