SAS Life Science Analytics Framework and the clinical data products from SAS

Error Message: "Unmatched brackets were detected" but Is It Really Macro Variable Resolution Problem

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

Error Message: "Unmatched brackets were detected" but Is It Really Macro Variable Resolution Problem

Hi All,

 I have a macro which is compiled prior to running my program in SDD.  This is the macro:

 

%macro mr_sql_pct(numerator=, denominator=, newvar=, label=, decimal=1);

catt(put((sum(&numerator)/&denominator)*100, 5.&decimal)) as &newvar label="&label",

%mend mr_sql_pct;

 

 I have code that is similar to the following:

 

proc sql noprint;

select count(distinct name) into :treated

from sashelp.class;

create table stats as

select

%mr_sql_pct(numerator=not missing(sex), denominator=%eval(&treated), newvar=pct, label=%)

sex label='Gender'

from sashelp.class

group by sex;

quit;

 

 This code runs correctly in PC SAS, but in SDD if I even try to hit 'save' I get a message "Unmatched brackets were detected in the following statement(s)" and then it highlights everything from "create" to the semicolon.  The program runs with errors, but I can't see where the unmatched brackets could possibly be.  I have other programs that run similar macros in SDD, and only the programs that use a macro variable reference in the call to a macro are the ones that are giving these errors.  So is the real problem the fact that I can't use this macro variable reference in the macro call?  Is there a way to fix this without significant re-coding?

 Thanks in advance for your help!

 

 Cheers,

Mary R.


Accepted Solutions
Solution
‎01-22-2016 11:28 AM
Occasional Contributor
Posts: 14

Re: Error Message: "Unmatched brackets were detected" but Is It Really Macro Variable Reso

We have figured out the issue with this and I wanted to post it here too:

 

The problem is with the '%)' in the macro call.  It seems that the '%' is masking the ')' in SDD, and that is causing the 'unmatched brackets' message.  The solution is to simply put a space between the '%' and the ')'. 

 

Thanks to all those who took a look a this question.

 

Cheers,

Mary R.

View solution in original post


All Replies
Solution
‎01-22-2016 11:28 AM
Occasional Contributor
Posts: 14

Re: Error Message: "Unmatched brackets were detected" but Is It Really Macro Variable Reso

We have figured out the issue with this and I wanted to post it here too:

 

The problem is with the '%)' in the macro call.  It seems that the '%' is masking the ')' in SDD, and that is causing the 'unmatched brackets' message.  The solution is to simply put a space between the '%' and the ')'. 

 

Thanks to all those who took a look a this question.

 

Cheers,

Mary R.

Community Manager
Posts: 2,639

Re: Error Message: "Unmatched brackets were detected" but Is It Really Macro Variable Reso

Glad you found it @MaryR!  I was about to ping @Lex_SAS and colleagues to make sure they saw the query.

SAS Employee
Posts: 47

Re: Error Message: "Unmatched brackets were detected" but Is It Really Macro Variable Reso

It is interesting that PC SAS did not have an issue with this .... Maybe a different SAS version compared to the one on SDD?

Trusted Advisor
Posts: 1,189

Re: Error Message: "Unmatched brackets were detected" but Is It Really Macro Variable Reso

@Lex_SAS why would PC SAS have a problem with it?

 

It looks like valid code to me.  The % alone should not be enough to mask the ), since it's not wrapped in %str().  At least, this simple example works fine:

1    %macro test(text=);
2    %put >>&text<<;
3    %mend test;
4    %test(text=some%)
>>some%<<

 

@MaryR's code also runs fine for me in PC SAS (9.3).

 

I don't know anything about SDD.  But if the error message pops up when she hits "SAVE", wouldn't that suggest it's some SDD code parser/syntax highlighter that is having the problem, not actually SAS tokenizer?

SAS Employee
Posts: 47

Re: Error Message: "Unmatched brackets were detected" but Is It Really Macro Variable Reso

@Quentin Obviously PC SAS did not have an issue with it, but SDD did. I'll pass it onto Tech Support, since I'm no SDD expert either.

Occasional Contributor
Posts: 14

Re: Error Message: "Unmatched brackets were detected" but Is It Really Macro Variable Reso

Thanks so much for your help!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 942 views
  • 4 likes
  • 4 in conversation