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.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

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
  • 12549 views
  • 3 likes
  • 4 in conversation