<?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: Check word present in a macro variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421813#M103731</link>
    <description>&lt;P&gt;Can you please elaborate the task that you want to accomplish?&lt;/P&gt;</description>
    <pubDate>Sun, 17 Dec 2017 02:01:48 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2017-12-17T02:01:48Z</dc:date>
    <item>
      <title>Check word present in a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421811#M103730</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a long macro variable (check) and&amp;nbsp;need to scan&amp;nbsp; the presence of a word&amp;nbsp; using a macro and in a data step ? How can I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let check=This is Year 2017, Month 12, Day 12;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;var= "Month";&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2017 01:09:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421811#M103730</guid>
      <dc:creator>Ram_SAS</dc:creator>
      <dc:date>2017-12-17T01:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Check word present in a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421813#M103731</link>
      <description>&lt;P&gt;Can you please elaborate the task that you want to accomplish?&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2017 02:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421813#M103731</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-12-17T02:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Check word present in a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421819#M103733</link>
      <description>&lt;P&gt;The safest tool is probably the FINDW function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let check=This is Year 2017, Month 12, Day 12;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;var="Month";&lt;/P&gt;
&lt;P&gt;if findw("&amp;amp;check", var) &amp;gt; 0 then flag=1;&lt;/P&gt;
&lt;P&gt;else flag=0;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to consider whether upper vs. lower case matters:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if findw(upcase("&amp;amp;check"), upcase(var)) &amp;gt; 0 then flag=1;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2017 03:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421819#M103733</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-17T03:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Check word present in a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421822#M103734</link>
      <description>&lt;P&gt;Thanks for your reply.&amp;nbsp; I should have posted bit more clearly. How do we flag here? Need to get the third one flagged.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let string=MONTH 1-ABC MONTH 0,MONTH 1-ABC MONTH 2,MONTH 1-ABC MONTH 3,MONTH 1-ABC MONTH 3,MONTH 5-ABC MONTH 6;&lt;BR /&gt;%put &amp;amp;=string;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;length var $100;&lt;BR /&gt;var="MONTH"; output;&lt;BR /&gt;var="MONTH 1-ABC MONTH 1"; output;&lt;BR /&gt;var="MONTH 1-ABC MONTH 2"; output;&lt;BR /&gt;var="MONTH 1-ABC MONTH 8"; output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;set test;&lt;BR /&gt;if findw("&amp;amp;string", var) &amp;gt; 0 then flag=1;&lt;BR /&gt;else flag=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2017 04:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421822#M103734</guid>
      <dc:creator>Ram_SAS</dc:creator>
      <dc:date>2017-12-17T04:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Check word present in a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421838#M103737</link>
      <description>&lt;P&gt;A slight change accomplishes this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if findw("&amp;amp;string", trim(var), ',') &amp;gt; 0 then flag=1;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This change tells the function to use commas as the only delimiters.&amp;nbsp; Note that this fails if the original macro variable contains blanks after the commas.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2017 12:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421838#M103737</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-17T12:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Check word present in a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421851#M103738</link>
      <description>&lt;P&gt;Excellent, Thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2017 16:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-word-present-in-a-macro-variable/m-p/421851#M103738</guid>
      <dc:creator>Ram_SAS</dc:creator>
      <dc:date>2017-12-17T16:27:27Z</dc:date>
    </item>
  </channel>
</rss>

