Your SAS programs, embedded in web apps and elsewhere

SAS ERROR: All positional parameters must precede keyword parameters.

Reply
Occasional Contributor
Posts: 14

SAS ERROR: All positional parameters must precede keyword parameters.

Stored Process is supposed to pass parameters to xls_output.sas file

At the first this was working, not sure why did I need data7= because without that it didn't work

SAS file

%macro xls_output(data1=, data2=, data4=, MTM_Status=, data5=, data6=, data7=);

Stored Process

%xls_output      (data1=aaa, data2=bbb, data4=ddd, data5=eee, data6=fff, MTM_Status=&&var1);

This didn't work

1)

SAS file

%macro xls_output(data1=, data2=, data4=, MTM_Status=, data5=, data6=);

Stored Process

%xls_output      (data1=aaa, data2=bbb, data4=ddd, data5=eee, data6=fff, MTM_Status=&&var1);

or this

2)

SAS file

%macro xls_output(data1=, data2=, data4=, MTM_Status=, data5=, data6=);

Stored Process

%xls_output      (data1=aaa, data2=bbb, data4=ddd, MTM_Status=&&var1, data5=eee, data6=fff);

Now after I added data3 it didn't work again

a)

SAS file

%macro xls_output(data1=, data2=, data3=, data4=, MTM_Status=, data5=, data6=, data7=);

Stored Process

%xls_output      (data1=aaa, data2=bbb, data3=ccc, data4=ddd, data5=eee, data6=fff, MTM_Status=&&var1);

and I got SAS Error below

SAS ERROR: All positional parameters must precede keyword parameters. ERROR 180-322: Statement is not valid or it is used out of proper order.

b)

After I tried this (didn't work and didn't get any error but Stored Process failed)

SAS file

%macro xls_output(data1=, data2=, data3=, data4=, MTM_Status=, data5=, data6=);

Stored Process

%xls_output      (data1=aaa, data2=bbb, data3=ccc, data4=ddd, MTM_Status=&&var1, data5=eee, data6=fff);

And then just for curiosity tried again a) but didn't get Error

SAS ERROR: All positional parameters must precede keyword parameters. ERROR 180-322: Statement is not valid or it is used out of proper order.

So, I am definitely confused. Any help is appreciated.

Super User
Posts: 3,102

Re: SAS ERROR: All positional parameters must precede keyword parameters.

What does &&var1 resolve to? If it contains an embedded comma then it could cause the error you are getting.

PROC Star
Posts: 1,230

Re: SAS ERROR: All positional parameters must precede keyword parameters.

Agree with re &&var1 possibly having an embedded comma.

Also suggest you try debugging the macro code outside of the stored process setting (i.e. using DM SAS, or Enterprise guide code window, or whatever).  A stored process is just SAS code.  Sometimes it's easiest to get the SAS code working first, and then wrap it inside a stored process.  Often my stored process source code is just a %INCLUDE of a .sas file or a macro call.

--Q.

Occasional Contributor
Posts: 14

Re: SAS ERROR: All positional parameters must precede keyword parameters.

&&var1does not have comma and Stored Process works perfectly in EG without xls_output statement.

Super User
Posts: 10,483

Re: SAS ERROR: All positional parameters must precede keyword parameters.

What does &&var1 resolve to? Other characters than comma may be an issue.

Also are the examples provided EXACTLY the same submitted or did you replace actual values with examples? If so, post an actual example.

Also, does your %xls_output  macro call any others? The actual issue might be in what the outer macro passes to the inner ones. Your comment "At the first this was working, not sure why did I need data7= because without that it didn't work" raises a number of questions about the role that data7 plays.

PROC Star
Posts: 1,230

Re: SAS ERROR: All positional parameters must precede keyword parameters.

In  EG program window, I would paste the definition of %xls_output, i.e.:


%macro xls_output(...);

...

%mend xls_output;

And debug xls_output there, testing different ways to invoke it with different parameters etc.

I think &&var1 is still suspicious.  You could add %put _local_ to your stored process code to see what it resolves to.

It's not clear what you mean by "didn't work" (got an error message? didn't run? ran but you didn't like the results).

Once you are at the point where you understand how %xls_output works and how it can be invoked, that should help with debugging your stored process.

Ask a Question
Discussion stats
  • 5 replies
  • 9170 views
  • 3 likes
  • 4 in conversation