Hi!
First, the way your macro is defined is causing you a problem. It should be more like this:
[pre]
%macro OutToExcel;
Proc EXPORT Data = whatever
OUTFILE="c:\sas\data\restrictedgifts.xls"
DBMS=excel2000
REPLACE;
RUN;
%mend OutToExcel;
[/pre]
However, you WILL still have problems because you'd need to invoke this from a CALL EXECUTE from within your data set.
Even if you fixed both of those things, you still have a third problem because you are making an incorrect assumption about SAS stored processes. You are making the assumption that every time the macro is run that you will be creating a file on the local system (c:\sas\data\restrictedgifts.xls ...but this is NOT correct .... you would be running the stored process on the workspace server or the stored process server and the results will come back to whichever client is open when they run the stored process. Unless you make a permanent package file, you cannot control the name of the results that get sent back to the BI client application. This stored process would NOT work in the Info Delivery Portal or in Web Report Studio, for example.
I would be tempted to write a stored process that could be executed from within the SAS Add-in for Microsoft Office this way (assuming that &title is a parameter coming from the stored process interface):
[pre]
%macro cktitle;
%if %upcase(&title) = NO %then %do;
proc print data=whatever;
run;
%end;
%else do;
%put ======> Checking TITLE parameter:
%put ======> To run this in Excel, select NO for the TITLE prompt;
%end;
%mend cktitle;
%global TITLE;
*ProcessBody;
%stpbegin;
%cktitle;
%stpend;
[/pre]
Then I would register the stored process to run on the server and return streaming or transient results. If the user submits this from EG, for example, they would create an HTML result by default & they could do an export to excel from EG or they could use the SAS Add-in for Microsoft Office in Excel and they could then execute the stored process and save the results to whatever file name they wanted on their local system.
If you registered this stored process as creating a permanent package file, then you could control where the package was saved and what to name it. BUT, the package would not contain an Excel file unless you did an explicit publish of the Excel file to the package.
For more help with your stored process, I recommend contacting Tech Support so they can follow through with you on exactly what it is you want to do, which client applications need to execute the stored process and how to best accomplish what you want to do.
cynthia