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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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?

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: 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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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