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.
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.
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.
Glad you found it @MaryR! I was about to ping @Lex_SAS and colleagues to make sure they saw the query.
It is interesting that PC SAS did not have an issue with this .... Maybe a different SAS version compared to the one on SDD?
@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?
@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.
Thanks so much for your help!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!
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.