DATA Step, Macro, Functions and more

Macro Error with Long Text

Accepted Solution Solved
Reply
Regular Contributor
Posts: 220
Accepted Solution

Macro Error with Long Text

I have some footnote text that I want to add to a table, but I am using at least 1 of 5 set footnotes as follows:

%let note1=Adverse event monitoring for treatment-emergent ~{super 99m}Tc-etarfolatide adverse events commences with dosing of ~{super 99m}Tc-etarfolatide and continues for 4 days.;

%let note2=Adverse events reported as 'possibly', 'probably' or 'definitely' related to investigational agent that occur beyond the 4-day reporting window are included in the ~{super 99m}Tc-etarfolatide safety reporting analyses.;

%let note3=Patients are counted once for each system organ class and for each preferred term.;

%let note4=Drug-related adverse events include those possibly, probably or definitely related.;

%let note5=Adverse events are coded in accordance with MedDRA v.15.1 Dictionary.;

I then use the footnotes in a macro call as follows:

%aeoutput(file=DR_SER,

tnum=14.3.5,

ttitle=%str(Frequency Table of Drug-Related Serious Adverse Events),

foot1=%str(&note1.),

foot2=%str(&note3.),

foot3=%str(&note4.),

foot4=%str($note5.),

whr=%str(ec20ae=1 & serious=1 & relate in (3,4,5)),

label=%str(Drug-Related Serious Adverse Event));

I have noticed that whenever I reference notes 2 or 4 that I get an error message in the log.

ERROR: all positional parameters must precede keyword parameters.

I have a feeling that it has something to do with the word "or" that occurs in each of those notes.  Is SAS trying to interpret that as an or ("|") operator?  If so, does anyone know of a work-around method to avoid this error message?


Accepted Solutions
Solution
‎07-19-2013 03:32 PM
Regular Contributor
Posts: 220

Re: Macro Error with Long Text

I resolved my own question!  It wasn't the "or" that I originally thought was causing the problem.  It also had nothing to do with the macro parameter order.  It didn't like the commas that were in the notes 2 and 4.  When I took out the commas, the code ran smoothly with no errors.

View solution in original post


All Replies
Occasional Contributor
Posts: 7

Re: Macro Error with Long Text

My guess is that when you defining the macro you are giving it more variables than you have listed. When defining macros SAS will either use the position or the keyword and it all depends on how you define it in the macro statement. For example

%Macro Test(A = 1, B, C);

...

%Mend;

A is a keyword parameter and B is a positional parameter. If you do %Macro Test(B, C, A = 1); then you shouldn't get this error. SAS does this so that say you have multiple positional variables and do the following:

%Macro Test(B, C, A = 1);

...

%Mend;

%TEST( , 2, );

So that B = NULL, C = 2 and A = 1.

Hope that helps.

Regular Contributor
Posts: 220

Re: Macro Error with Long Text

BHarmon,

Thank you for your reply.  I have played around a bit with your suggestions, but I still get the same errors.  This is what the macro statement looks like:

%macro aeoutput(whr=%str(1=1), file=, tnum=, ttitle=%str(), foot1=%str(), foot2=%str(), foot3=%str(), foot4=%str(), foot5=%str(), label=%str());

And this is the error messages that results when I run the macro call as displayed in my original post:

48796 %aeoutput(file=DR_SER,

48797            tnum=14.3.5,

48798            ttitle=%str(Frequency Table of Drug-Related Serious Adverse Events),

48799            foot1=%str(&note1.),

48800            foot2=%str(&note3.),

48801            foot3=%str(&note4.),

ERROR: All positional parameters must precede keyword parameters.

48802            foot4=%str($note5.),

                 -----

                 180

ERROR 180-322: Statement is not valid or it is used out of proper order.

48803 whr=%str(ec20ae=1 & serious=1 & relate in (3,4,5)),

48804            label=%str(Drug-Related Serious Adverse Event));



Does this help clarify in any way?

Regular Contributor
Posts: 220

Re: Macro Error with Long Text

Just to clarify, I did move the "whr" portion to the end of the macro statement, and that didn't make a difference.

Solution
‎07-19-2013 03:32 PM
Regular Contributor
Posts: 220

Re: Macro Error with Long Text

I resolved my own question!  It wasn't the "or" that I originally thought was causing the problem.  It also had nothing to do with the macro parameter order.  It didn't like the commas that were in the notes 2 and 4.  When I took out the commas, the code ran smoothly with no errors.

Frequent Contributor
Posts: 129

Re: Macro Error with Long Text

Just an observation.  This illustrates an application where macro quoting functions might be helpful to prevent this kind of error without output modifying the presentaion:-)

Frequent Contributor
Posts: 129

Re: Macro Error with Long Text

Instead of '...output modifying the presentaion', I meant 'changes which modify the presentation output'

Occasional Contributor
Posts: 7

Re: Macro Error with Long Text

Glad to hear you found the problem.

☑ This topic is SOLVED.

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

Discussion stats
  • 7 replies
  • 254 views
  • 0 likes
  • 3 in conversation