Usually, your CALL EXECUTE is within a DATA step program like this:
[pre]
data whatever;
set something;
call execute(argument);
run;
[/pre]
Where you want to EXECUTE some set of statements for every observation in the input data set or for some selected subset (like the first or where a condition is met). According to the documentation:
If argument resolves to a macro invocation, the macro executes immediately and DATA step execution pauses while the macro executes. If argument resolves to a SAS statement or if execution of the macro generates SAS statements, the statement(s) execute after the end of the DATA step that contains the CALL EXECUTE routine. CALL EXECUTE is fully documented in SAS Macro Language: Reference.
So it is possible that you have some timing issues if your CALL EXECUTE it in a DATA step program which is IN a macro program and IS CALLING another macro program which generate PROC REPORT statements.
I call your attention to this SUGI paper:
http://www2.sas.com/proceedings/sugi30/027-30.pdf
It outlines many of the pitfalls of CALL EXECUTE. There are other problems that you may run into that are just related to quoting issues in your CALL EXECUTE statement. I generally follow these steps when developing a macro program:
1) have a working SAS program with no macro variable references that produces the output I want for one condition or group
2) Modify the working SAS program to include variable references such as
%let group = Asia;
where Region = "&group";
to make sure that my macro variable substitution will result in the same report as my hardcoded example.
3) Make a macro program that can be invoked repetitively for each one of a group:
%doreg(group=Asia)
%doreg(group=Pacific)
%doreg(group=Canada)
...and make sure that the macro program generates the correct output for each selection
4) At this point I have 2 choices:
a) write a program to dynamically generate the macro invocations as shown in 3 and then %include the file with the generated code
OR
b) write a program to use CALL EXECUTE to invoke the macro directly from within the DATA step program.
I would probably do 4a first before I moved onto 4b because resolving issues in 4a would help me decide whether I was going to have timing issues in 4b, depending on what kinds of SAS statements my macro program was generating. And, I frequently find that my macro programs are not so complex that I need to move to 4b after I have successfully written program 4a. For example:
[pre]
** define the macro program from working SAS program;
** group is for my where statement;
** fname is for the filename in the ODS statement;
** way is for the filename -- either;
** include method (way=INCL) or ;
** call execute method (way=CEXEC);
** Also, use a bit of conditional logic in the;
** PROC REPORT code;
** I need a variable for the WHERE clause that will match what is in the data (&group);
** BUT I do NOT want to have a / in the PDF file name because my operating;
** system does not allow special characters in filenames. so my filename;
** will come from &FNAME.&WAY macro variables concatenated together;
%macro doreg(group= , fname=, way=);
ods pdf file="c:\temp\&fname.&way..pdf";
title "&Group Report: File is &fname.&way..pdf";
proc report data=sashelp.shoes nowd;
where region = "&group";
column region product sales;
define region / group;
define product/group;
%if &group = Asia %then %do;
define sales /sum 'Asia Sales';
%end;
%else %do;
define sales/ sum 'Other Sales';
%end;
rbreak after /summarize;
run;
ods pdf close;
%mend;
** 3) Prove that my macro program can be invoked repetitively;
** and that it produces the correct output;
%doreg(group=Asia, fname=Asia, way=REP);
%doreg(group=Canada, fname=Canada, way=REP);
** 4a) make an ASCII text file with the invocation statements;
data makelist;
set sashelp.shoes;
by Region;
if first.region then do;
fname = translate(Region,' ','/');
fname = left(compress(fname));
file 'c:\temp\invoke_reg.txt';
put @1 '%doreg(group=' Region ', fname=' fname ',way=INCL);';
end;
run;
** 4a) now invoke the macro program for each region using the TXT file;
** look at the TXT file in NOTEPAD to see what was generated;
%include 'c:\temp\invoke_reg.txt';
** 4b) Turn 4a program into a CALL EXECUTE program;
** make an ASCII text file with the invocation statements;
** I prefer to build my invocation statement into a program variable name;
data makelist;
set sashelp.shoes;
by Region;
if first.region then do;
fname = translate(Region,' ','/');
fname = left(compress(fname));
invoke = '%doreg(group='||trim(Region)|| ', fname='||trim(fname)||',way=CEXEC)';
call execute(invoke);
end;
run;
[/pre]
If you are having a problem, I suggest that you go all the way back to step 1 and make sure you have a working SAS program (without call execute). Then go to step 2 and make sure that your program (PROC REPORT) works correctly to create ONE PDF file when you insert simple macro variable references into the program. Then move to step 3 and design a macro program that can be invoked repetitively and produces the correct output for each group. Then move to step 4a.
By that point, I'm betting that you will have discovered all your various issues. Otherwise, my only other idea would be for you to contact Tech Support for further help.
cynthia