BookmarkSubscribeRSS Feed
pope1970
Calcite | Level 5

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.

5 REPLIES 5
SASKiwi
PROC Star

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

Quentin
Super User

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.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
pope1970
Calcite | Level 5

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

ballardw
Super User

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.

Quentin
Super User

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.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 13442 views
  • 3 likes
  • 4 in conversation