BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MaryR
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
MaryR
Fluorite | Level 6

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

6 REPLIES 6
MaryR
Fluorite | Level 6

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.

ChrisHemedinger
Community Manager

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

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Lex_SAS
SAS Employee

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

Quentin
Super User

@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?

Lex_SAS
SAS Employee

@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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

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