<?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: required operator not found in simple SAS macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/required-operator-not-found-in-simple-SAS-macro/m-p/502153#M134015</link>
    <description>&lt;P&gt;You are mixing and matching macro commands with data step commands. You can't do that. When you put variables inside quotes, that works in a data step but not with macro variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;region_data=Brazil or &amp;amp;region_data=HK or /*you type the rest*/ ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 06 Oct 2018 17:56:55 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-10-06T17:56:55Z</dc:date>
    <item>
      <title>required operator not found in simple SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/required-operator-not-found-in-simple-SAS-macro/m-p/502151#M134013</link>
      <description>&lt;P&gt;I am trying to use a SAS macro to do a conditional procedure. I set a region name, and if it's in a subset then I want it to do something differently. The code is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro merge_RF(region_data);		
	%if "&amp;amp;region_data" in ('Brazil', 'HK', 'Malaysia', 'Singapore', 'Taiwan', 'Thailand') %then %do;		* for regions with no better data, use MPT risk free index;
		proc sort data = ts_fund2; by Risk_Free_Rate_ID date; run;
		data ts_fund3;
			merge ts_fund2 (in = a) use.idx5;
			by Risk_Free_Rate_ID date;
			if a;
		run;
	%end;	
	%else %do;
		proc sort data = ts_fund2; by date; run;
		data ts_fund3;
			merge ts_fund2 (in = a) use.OECD_rf2 (where = (region = "&amp;amp;region_data"));			
			by date;
			if a;
		run;
	%end;
%mend merge_RF;

%merge_RF(region_input);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, when I run it, the error message I got is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P class="1538847445167"&gt;ERROR: Required operator not found in expression: "&amp;amp;region_data" in ('Brazil', 'HK', 'Malaysia',&lt;BR /&gt;'Singapore', 'Taiwan', 'Thailand')&lt;BR /&gt;ERROR: The macro MERGE_RF will stop executing.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P class="1538847445167"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="1538847445167"&gt;What's wrong in my code?&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="1538847445167"&gt;Edit:&lt;/P&gt;&lt;P class="1538847445167"&gt;I forgot to mention this: the input region (region_input) is a macro variable defined earlier, such as&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let region = Japan;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Oct 2018 17:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/required-operator-not-found-in-simple-SAS-macro/m-p/502151#M134013</guid>
      <dc:creator>xyxu</dc:creator>
      <dc:date>2018-10-06T17:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: required operator not found in simple SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/required-operator-not-found-in-simple-SAS-macro/m-p/502153#M134015</link>
      <description>&lt;P&gt;You are mixing and matching macro commands with data step commands. You can't do that. When you put variables inside quotes, that works in a data step but not with macro variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;region_data=Brazil or &amp;amp;region_data=HK or /*you type the rest*/ ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 17:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/required-operator-not-found-in-simple-SAS-macro/m-p/502153#M134015</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-10-06T17:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: required operator not found in simple SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/required-operator-not-found-in-simple-SAS-macro/m-p/502154#M134016</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options minoperator;
%macro merge_RF(region_data)/mindelimiter=',';	
	%if &amp;amp;region_data in (Brazil, HK, Malaysia, Singapore, Taiwan, Thailand) %then %do;		* for regions with no better data, use MPT risk free index;
		proc sort data = ts_fund2; by Risk_Free_Rate_ID date; run;
		data ts_fund3;
			merge ts_fund2 (in = a) use.idx5;
			by Risk_Free_Rate_ID date;
			if a;
		run;
	%end;	
	%else %do;
		proc sort data = ts_fund2; by date; run;
		data ts_fund3;
			merge ts_fund2 (in = a) use.OECD_rf2 (where = (region = "&amp;amp;region_data"));			
			by date;
			if a;
		run;
	%end;
%mend merge_RF;

%merge_RF(region_input);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Oct 2018 17:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/required-operator-not-found-in-simple-SAS-macro/m-p/502154#M134016</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-06T17:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: required operator not found in simple SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/required-operator-not-found-in-simple-SAS-macro/m-p/502157#M134019</link>
      <description>&lt;P&gt;The keyword IN is not normally an operator in macro code. You need to set options to enable macro language to treat IN as having a special meaning. If your macro requires that then set the options on the macro definition and it will override any system options that the calling user might have set.&lt;/P&gt;
&lt;P&gt;Also note that quotes are just part of the string to the macro processor. So "Brazil" will never equal 'Brazil'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro merge_RF(region_data) / minoperator mindelimiter='|';
%local byvars;

%let byvars=date;
%if %upcase(&amp;amp;region_data) in %upcase(Brazil|HK|Malaysia|Singapore|Taiwan|Thailand) %then 
  %let byvars= Risk_Free_Rate_ID &amp;amp;byvars
;

proc sort data = ts_fund2;
  by &amp;amp;byvars;
run;
data ts_fund3;
  merge ts_fund2 (in = a) use.idx5;
  by &amp;amp;byvars;
  if a;
run;

%mend merge_RF;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Oct 2018 18:18:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/required-operator-not-found-in-simple-SAS-macro/m-p/502157#M134019</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-06T18:18:39Z</dc:date>
    </item>
  </channel>
</rss>

