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
Opal | Level 21

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

Quentin
PROC Star

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.

Check out the Boston Area SAS Users Group (BASUG) video archives: https://www.basug.org/videos.
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
PROC Star

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.

Check out the Boston Area SAS Users Group (BASUG) video archives: https://www.basug.org/videos.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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