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.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
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?

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3639 views
  • 4 likes
  • 4 in conversation