<?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: ERROR: Expected close parenthesis after macro function invocation not found. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694989#M212007</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/354451"&gt;@sasknewB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi, I am not too familiar with the BY group processing. Would you be able to give an example of how I would be able to use BY group processing to accomplish my goal?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It really depends on what your goal is.&amp;nbsp; So far it looks like you have just presented an&amp;nbsp;&lt;A href="http://xyproblem.info/" target="_self"&gt;XY problem&lt;/A&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;If the goal is to analyze TEST3 by different levels of GROUP then just add a BY statement to your analysis step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=test3;
  by group;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 28 Oct 2020 19:13:17 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-10-28T19:13:17Z</dc:date>
    <item>
      <title>ERROR: Expected close parenthesis after macro function invocation not found.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694747#M211896</link>
      <description>&lt;P&gt;(I am using SAS Enterprise Guide Version 7.15 HF7)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi, I have tried to debug this code for hours without luck. The error message I am getting is: "ERROR: Expected close parenthesis after macro function invocation not found."&lt;/P&gt;&lt;P&gt;The code &lt;FONT color="#FF0000"&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(anyalpha(&amp;amp;MyVar.)) ge 1 %then %do;&lt;/CODE&gt;&lt;/FONT&gt; is where the error stems from. I believe it has to do with the fact that I am using %sysfunc and anyalpha together. On a separate post I read, I believe the error might be from the fact that there is "&lt;SPAN&gt;usage of macro statements where normal data-step-statements are required." I am no SAS expert, and I do not know what that means. I would appreciate any help. Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let input_var2 =		group; 
	data _NULL_;
	 if 0 then set work.test3 nobs=n;
	 call symputx('num_obs',n);
	 stop;
	run;
	%put no. of observations = &amp;amp;num_obs;&lt;BR /&gt;
%MACRO SPLIT;
	%DO I = 1 %TO &amp;amp;num_obs;
	/* creating a dataset for each unique entry from the input_var2 list */ 
		data _null_;
			set work.test3(obs=&amp;amp;I. firstobs=&amp;amp;I. keep = &amp;amp;input_var2.);	
			call symputx('MyVar', &amp;amp;input_var2.);
	        stop;
		run;
	%put &amp;amp;MyVar.;
&lt;FONT color="#CC99FF"&gt;	%if %sysfunc(anyalpha(&amp;amp;MyVar.)) ge 1 %then %do;&lt;/FONT&gt;
		%let MyVar2 = "&amp;amp;MyVar.";
	%end;
	%else %do;
		%let MyVar2 = &amp;amp;MyVar.;
	%end;
	%put &amp;amp;MyVar2.;

		data work.&amp;amp;input_var2.&amp;amp;I.;
			set work.test;
			where &amp;amp;input_var2 = &amp;amp;MyVar2.;
		run;
	%END;
%MEND SPLIT; 

options mlogic symbolgen  MLOGICNEST;
%SPLIT&lt;/CODE&gt;&lt;/PRE&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 06:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694747#M211896</guid>
      <dc:creator>sasknewB</dc:creator>
      <dc:date>2020-10-28T06:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expected close parenthesis after macro function invocation not found.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694758#M211899</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the value of &amp;amp;MyVar. when the error occurs ?&lt;/P&gt;
&lt;P&gt;For instance, if it contains a semi-column, the generated code may&lt;/P&gt;
&lt;P&gt;prematurely terminate the %if instruction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, i don't think the way you define &amp;amp;MyVar2. is correct, that is with or&lt;/P&gt;
&lt;P&gt;without double quotes whether &amp;amp;MyVar. contains alphabetic characters or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Indeed, you use it in the subsequent where clause, but the group column of the&lt;/P&gt;
&lt;P&gt;work.test dataset is either numeric or character so the value of &amp;amp;MyVar2. should&lt;/P&gt;
&lt;P&gt;be consistent for all iterations of your %do loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 08:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694758#M211899</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2020-10-28T08:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expected close parenthesis after macro function invocation not found.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694761#M211901</link>
      <description>&lt;P&gt;Also, why don't you simply use the implicit loop of the data step ?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 08:33:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694761#M211901</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2020-10-28T08:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expected close parenthesis after macro function invocation not found.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694762#M211902</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/354451"&gt;@sasknewB&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's nice to see you've done your research. Upon initial inspection I don't see anything immediately obviously wrong.&lt;/P&gt;
&lt;P&gt;Do you have any previous macros that you are calling, as the error indicates an issue with the invocation of a macro? If not then try closing your SAS session and trying again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't see any&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;"&lt;/SPAN&gt;&lt;SPAN&gt;usage of macro statements where normal data-step-statements are required." This means a data step contains macro statements, where one would expect only data step statements, e.g., a variable assignment should be &lt;FONT face="courier new,courier"&gt;var = value;&lt;/FONT&gt;, but instead &lt;FONT face="courier new,courier"&gt;%let var = value;&lt;/FONT&gt; has been used.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please also share the relevant section of the log using the "Insert Code" icon as this might yield more clues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 08:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694762#M211902</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-10-28T08:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expected close parenthesis after macro function invocation not found.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694764#M211903</link>
      <description>&lt;P&gt;I think you want something as (not tested) :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;		data _null_;
			set work.test3(keep = &amp;amp;input_var2.);	
            call execute(cats("data work.input_var2.",_N_,"; set work.test; where &amp;amp;input_var2.=",&amp;amp;input_var2.,"; run;"));
		run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;EDIT : A more complete macro that checks the column type :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test3;
    input group $ val;
    cards;
A 1
B 2
C 3
D 4
;
run;

data test;
    input group $ val;
    cards;
A 1
C 3
;
run;

%macro split(input_var2);
    data _null_;
        set work.test3(keep = &amp;amp;input_var2.);	
        if vtype(&amp;amp;input_var2.)="C" then do;
            call execute(cats("data work.&amp;amp;input_var2.",_N_,"; set work.test; where &amp;amp;input_var2.='",&amp;amp;input_var2.,"'; run;"));
        end;
        else do;
            call execute(cats("data work.&amp;amp;input_var2.",_N_,"; set work.test; where &amp;amp;input_var2.=",&amp;amp;input_var2.,"; run;"));
        end;
    run;
%mend;

%split(group);
%split(val);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am not sure you really need to do that though. Why do you want to split your datasets this way ?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 09:53:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694764#M211903</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2020-10-28T09:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expected close parenthesis after macro function invocation not found.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694880#M211963</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/354451"&gt;@sasknewB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;(I am using SAS Enterprise Guide Version 7.15 HF7)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi, I have tried to debug this code for hours without luck. The error message I am getting is: "ERROR: Expected close parenthesis after macro function invocation not found."&lt;/P&gt;
&lt;P&gt;The code &lt;FONT color="#FF0000"&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(anyalpha(&amp;amp;MyVar.)) ge 1 %then %do;&lt;/CODE&gt;&lt;/FONT&gt; is where the error stems from. I believe it has to do with the fact that I am using %sysfunc and anyalpha together. On a separate post I read, I believe the error might be from the fact that there is "&lt;SPAN&gt;usage of macro statements where normal data-step-statements are required." I am no SAS expert, and I do not know what that means. I would appreciate any help. Thanks!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let input_var2 =		group; 
	data _NULL_;
	 if 0 then set work.test3 nobs=n;
	 call symputx('num_obs',n);
	 stop;
	run;
	%put no. of observations = &amp;amp;num_obs;&lt;BR /&gt;
%MACRO SPLIT;
	%DO I = 1 %TO &amp;amp;num_obs;
	/* creating a dataset for each unique entry from the input_var2 list */ 
		data _null_;
			set work.test3(obs=&amp;amp;I. firstobs=&amp;amp;I. keep = &amp;amp;input_var2.);	
			call symputx('MyVar', &amp;amp;input_var2.);
	        stop;
		run;
	%put &amp;amp;MyVar.;
&lt;FONT color="#CC99FF"&gt;	%if %sysfunc(anyalpha(&amp;amp;MyVar.)) ge 1 %then %do;&lt;/FONT&gt;
		%let MyVar2 = "&amp;amp;MyVar.";
	%end;
	%else %do;
		%let MyVar2 = &amp;amp;MyVar.;
	%end;
	%put &amp;amp;MyVar2.;

		data work.&amp;amp;input_var2.&amp;amp;I.;
			set work.test;
			where &amp;amp;input_var2 = &amp;amp;MyVar2.;
		run;
	%END;
%MEND SPLIT; 

options mlogic symbolgen  MLOGICNEST;
%SPLIT&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Creating macros that have macro variables just appear in the middle of code is poor practice. Since you are not explicitly setting them as parameters you can run into scope issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And in this case, we have no clue what your macro variables:&lt;BR /&gt;&amp;amp;input_var2&lt;/P&gt;
&lt;P&gt;&amp;amp;myvar&lt;/P&gt;
&lt;P&gt;might actually contain.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Might consider using the OPTION MPRINT to show more of the code generated.&lt;/P&gt;
&lt;P&gt;Then share that with us from the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is also the entire question of why you think it is necessary to create a separate data set for each value of a variable. I would say that an extremely high percentage of cases where that my be considered are better off leaving the data in one set and using BY group processing.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 14:25:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694880#M211963</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-28T14:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expected close parenthesis after macro function invocation not found.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694900#M211971</link>
      <description>&lt;P&gt;Hi everyone, thanks for your prompt replies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the dataset work.test3:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sasknewB_0-1603897582334.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51170iFB73280A123AEDA0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sasknewB_0-1603897582334.png" alt="sasknewB_0-1603897582334.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is some output from the log&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MLOGIC(SPLIT):  Beginning execution.
SYMBOLGEN:  Macro variable NUM_OBS resolves to 5
MLOGIC(SPLIT):  %DO loop beginning; index variable I; start value is 1; stop value is 5; by value is 1.  
MPRINT(SPLIT):   data _null_;
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable INPUT_VAR2 resolves to group
MPRINT(SPLIT):   set work.test3(obs=1 firstobs=1 keep = group);
SYMBOLGEN:  Macro variable INPUT_VAR2 resolves to group
MPRINT(SPLIT):   call symputx('MyVar', group);
MPRINT(SPLIT):   stop;
MPRINT(SPLIT):   run;
MLOGIC(SPLIT):  %PUT &amp;amp;MyVar.
SYMBOLGEN:  Macro variable MYVAR resolves to a:(0to30K]
a:(0to30K]
SYMBOLGEN:  Macro variable MYVAR resolves to a:(0to30K]
ERROR: Expected close parenthesis after macro function invocation not found.
MLOGIC(SPLIT):  %IF condition %sysfunc(anyalpha(&amp;amp;MyVar.)) ge 1 is TRUE
MLOGIC(SPLIT):  %LET (variable name is MYVAR2)
SYMBOLGEN:  Macro variable MYVAR resolves to a:(0to30K]
MLOGIC(SPLIT):  %PUT &amp;amp;MyVar2.
SYMBOLGEN:  Macro variable MYVAR2 resolves to "a:(0to30K]"
"a:(0to30K]"
SYMBOLGEN:  Macro variable INPUT_VAR2 resolves to group
SYMBOLGEN:  Macro variable I resolves to 1
MPRINT(SPLIT):   data work.group1;
MPRINT(SPLIT):   set work.test;
SYMBOLGEN:  Macro variable INPUT_VAR2 resolves to group
SYMBOLGEN:  Macro variable MYVAR2 resolves to "a:(0to30K]"
MPRINT(SPLIT):   where group = "a:(0to30K]";
MPRINT(SPLIT):   run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Something to mention, is that work.test3 isn't guaranteed to be those variables. Sometimes it would be different categories such as years: 2012, 2013, ..., 2020. So when the categories are numbers, the where= data statement should be where group = 2020 while with the categories in the image it should be where group = "a:(0to30K]". So there is a difference in quotation marks.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 15:19:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694900#M211971</guid>
      <dc:creator>sasknewB</dc:creator>
      <dc:date>2020-10-28T15:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expected close parenthesis after macro function invocation not found.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694905#M211974</link>
      <description>&lt;P&gt;The very obvious question first:&lt;/P&gt;
&lt;P&gt;why do you split a dataset into subdatasets, when the variable used for splitting can easily be used for BY group processing?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 15:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694905#M211974</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-28T15:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expected close parenthesis after macro function invocation not found.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694975#M212003</link>
      <description>Hi, I am not too familiar with the BY group processing. Would you be able to give an example of how I would be able to use BY group processing to accomplish my goal?</description>
      <pubDate>Wed, 28 Oct 2020 18:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694975#M212003</guid>
      <dc:creator>sasknewB</dc:creator>
      <dc:date>2020-10-28T18:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expected close parenthesis after macro function invocation not found.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694989#M212007</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/354451"&gt;@sasknewB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi, I am not too familiar with the BY group processing. Would you be able to give an example of how I would be able to use BY group processing to accomplish my goal?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It really depends on what your goal is.&amp;nbsp; So far it looks like you have just presented an&amp;nbsp;&lt;A href="http://xyproblem.info/" target="_self"&gt;XY problem&lt;/A&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;If the goal is to analyze TEST3 by different levels of GROUP then just add a BY statement to your analysis step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=test3;
  by group;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Oct 2020 19:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694989#M212007</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-28T19:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expected close parenthesis after macro function invocation not found.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694994#M212008</link>
      <description>&lt;P&gt;You have not protected your macro code from unbalanced quotes in the value of the macro variable you created from a dataset variable.&amp;nbsp; Most likely in this line:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(anyalpha(&amp;amp;MyVar.)) ge 1 %then %do&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could convert to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(anyalpha(%superq(MyVar))) ge 1 %then %do&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But really you should just figure out if the variable is numeric or character upfront.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
   if 0 then set work.test3 nobs=n;
   call symputx('num_obs',n);
   call symputx('var_type',vtype(&amp;amp;input_var2));
   stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then your later code becomes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.&amp;amp;input_var2.&amp;amp;I.;
  set work.test;
  where &amp;amp;input_var2 = 
%if &amp;amp;var_type=C %then "&amp;amp;MyVar" ;
%else &amp;amp;MyVar;
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 19:22:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expected-close-parenthesis-after-macro-function-invocation/m-p/694994#M212008</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-28T19:22:05Z</dc:date>
    </item>
  </channel>
</rss>

