<?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: How to check if a macro variable contains certain strings? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-check-if-a-macro-variable-contains-certain-strings/m-p/376523#M24464</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro runTEST(dataName);

 %if %index(&amp;amp;dataName.,test) %then %do;   /* something wrong here */
    %put FOUND TEST;
    %end; 
   %else %do;
   	%put NO TEST;
   %end;

%mend runTEST;
%runTEST(test)
%runTEST(hello_test123)
%runTEST(random)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Jul 2017 13:02:39 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-07-17T13:02:39Z</dc:date>
    <item>
      <title>How to check if a macro variable contains certain strings?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-check-if-a-macro-variable-contains-certain-strings/m-p/376390#M24449</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* sample dataset */
data have;
  infile datalines dlm=",";
  input date $ value;
datalines;
05AUG2010,5
;
run;


/* macro to calculate percentage */
%macro test11;
%global valueMax;
%let valueMAX = 10;

data WORK.have_adj;
set WORK.have;

format perc best8.;
perc = value/&amp;amp;valueMAX.;
run;

%mend test11;


/* macro to execute */
%let dataName = test;
%macro runTEST;

 %if %sysfunc(find("&amp;amp;dataName.",'test')) ge 1 %then %do;   /* something wrong here */
    %test11; 
    %end; 

%mend runTEST;
%runTEST;

/* check whether macro 'test' has been executed */
%put _ALL_;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The result suggests the macro 'test11' has not been executed. How to fix it?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 02:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-check-if-a-macro-variable-contains-certain-strings/m-p/376390#M24449</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-07-17T02:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a macro variable contains certain strings?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-check-if-a-macro-variable-contains-certain-strings/m-p/376391#M24450</link>
      <description>&lt;P&gt;Remove the quotes from the macro variable in the FIND function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Modified your code for testing to make it easier:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro runTEST(dataName);

 %if %sysfunc(find(&amp;amp;dataName.,test)) ge 1 %then %do;   /* something wrong here */
    %put FOUND TEST;
    %end; 
   %else %do;
   	%put NO TEST;
   %end;

%mend runTEST;
%runTEST(test);
%runTEST(hello_test123);
%runTEST(random);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jul 2017 03:05:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-check-if-a-macro-variable-contains-certain-strings/m-p/376391#M24450</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-17T03:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a macro variable contains certain strings?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-check-if-a-macro-variable-contains-certain-strings/m-p/376393#M24451</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;for both the answer and tips! That solves the problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 03:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-check-if-a-macro-variable-contains-certain-strings/m-p/376393#M24451</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-07-17T03:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a macro variable contains certain strings?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-check-if-a-macro-variable-contains-certain-strings/m-p/376523#M24464</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro runTEST(dataName);

 %if %index(&amp;amp;dataName.,test) %then %do;   /* something wrong here */
    %put FOUND TEST;
    %end; 
   %else %do;
   	%put NO TEST;
   %end;

%mend runTEST;
%runTEST(test)
%runTEST(hello_test123)
%runTEST(random)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jul 2017 13:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-check-if-a-macro-variable-contains-certain-strings/m-p/376523#M24464</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-07-17T13:02:39Z</dc:date>
    </item>
  </channel>
</rss>

