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

Hi,

 

I'm trying to run this code and it runs through the mod=1 cycle just fine.  No errors.  But the minute it gets to %mod(mod=2), then it says:

ERROR: All positional parameters must precede keyword parameters.
41         %mod(mod=2);

/*Add three variables from the PayerOnESRD dataset to the ALL $Ds and split out for M and N.*/
%macro mod(mod=);
    %macro splitd(lib=,type=,chgdt=,chgtype=);
    %do year4=&start. %to &end.;
        %let yr = %eval(%substr(&year4,3,2));

        proc sql;
            create table &lib..inc_&mod.y&yr. as
            select a.*,
                    b.esrdpaystat as paystat,
                    b.&chgdt. as paychgdt,
                    b.&chgtype. as paychgtype
            from ialld.in_&mod.y&yr. a left join pay.payeronesrd b
            on a.kecc_id=b.kecc_id
            where ESRDM="&type.";
        quit;
    %end;
    %mend splitd;
    %splitd(lib=imd,    type=M,    chgdt=M2NMChgDt,    chgtype=m2nmchgtype);
    %splitd(lib=inmd,    type=NM,chgdt=NM2MChgDt,    chgtype=nm2mchgtype);
%mend;
%mod(mod=1);
%mod(mod=2);
%mod(mod=5);
%mod(mod=6);

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
MeganE
Pyrite | Level 9

Weird, it didn't crash this time.

 

Cripes.  Ok, thanks!

View solution in original post

5 REPLIES 5
Astounding
PROC Star

Absolute speculation ...

 

Purely a wild guess ...

 

It looks like you are willing to use a system of defining macros within another macro (usually frowned upon!).  Also, I imagine that you have simplified your code to make your question manageable in size.  So, what I suspect ...

 

Within your system of macros calling macros, one of the macros redefines the meaning of %MOD.  So the second time, it means something totally different than what it did the first time.

MeganE
Pyrite | Level 9

I nest macros quite often....  *looks around questioningly...*

 

And no, it was a straight copy paste of the code.

 

What do you mean im redefining the meaning of %mod.  Where?  It's just used for the naming of files. I did re-try it, by changing the outer macro to %modx instead, wondering if using the same name for the macro and the macro var was causing it, but i still got the same error.

 

 EDIT: The only part of the actual code i left out from the above copy were the values of &start and &end and the libnames.  1978 and 2015.

russt_sas
SAS Employee

I ran the code and was unable to replicate your error.  Could you run it again in a new SAS session and attach the new log?

MeganE
Pyrite | Level 9

Weird, it didn't crash this time.

 

Cripes.  Ok, thanks!

FreelanceReinh
Jade | Level 19

Hi @MeganE,

 

Normally, this error message occurs only if you specify something in a macro call which SAS interprets as a positional parameter.

 

Examples:

%mod(mod=1,2);
%mod(mod=1,);

Typically in such cases, people try to pass a value containing a comma to a keyword parameter and forget to quote the comma or the entire value (e.g. by using the %STR function).

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 991 views
  • 0 likes
  • 4 in conversation