In Enterprise Guide, from within a stored process, is it possible to both export to Excel and to create a report? My stored process code appears to run successfully, but all I get is a report, and no excel file in my specified folder. Here is the piece of code that I am trying to execute:
data reset;
if ( UPCASE("&title")='YES') then do;
if _n eq 1 then
flag = 0;
else flag = flag + 1;
if flag >= 11 then do;
pageit + 1;
flag = 0;
end;
set sortfile;
end;
else set sortfile;
run;
%macro OutToExcel;
%if ( "&title"='NO') %then %do;
Proc EXPORT Data = sortfile;
OUTFILE="c:\SAS\data\restrictedgifts.xls";
DBMS=excel2000;
REPLACE;
RUN;
%end;
%mend OutToExcel;
%OutToExcel;
RUN;
/*****************************************************************************************/
/* The next lines of code "set up" the report headers to be printed. Depending */
/* on whether the data is to be exported to Excel, the headers will either */
/* contain data or be blank. */
/*****************************************************************************************/
TITLE;
TITLE1 &title1;
TITLE2 &title2;
TITLE3 &title3;
FOOTNOTE;
FOOTNOTE1 &footnote1;
FOOTNOTE2 &footnote2;
OPTIONS noBYLINE;
OPTIONS orientation=landscape;
proc report data=sortfile spacing=1 style(Header)={font_size=1.0 font_weight=medium} split='*' missing;
/*****************************************************************************************/
/* The following code prints the data in a report format */
/*****************************************************************************************/
COLUMN ORGANIZATION_DESC FUND ORGANIZATION_CODE ACCOUNT PROGRAM ACTIVITY ACCOUNT_POOL ACCOUNT_TYPE_LEVEL_1
ACCOUNT_TYPE_DESC_1 PROGRAM_DESC ATTRIBUTE_TYPE ACCOUNT_DESC SUM_ADOPTED_BUDGET
SUM_BUDGET_ADJUSTMENTS SUM_ACCUMULATED_BUDGET SUM_BUDGET_RESERVATION SUM_ENCUMBRANCES
CURR_YEAR_TO_DATE_ACTIVITY SUM_YEAR_TO_DATE_ACTIVTY SUM_REMAINING_BALANCE;
DEFINE ORGANIZATION_DESC / DISPLAY "ORG DESC" style=[just=l font_weight=demi_bold font_size=1.0];
DEFINE FUND / DISPLAY "FUND" style=[just=l font_weight=demi_bold font_size=1.0];
DEFINE ORGANIZATION_CODE / DISPLAY "ORG CODE" style=[just=l font_weight=demi_bold font_size=1.0];
DEFINE ACCOUNT / DISPLAY "ACCT" style=[just=l font_weight=demi_bold font_size=1.0];
DEFINE PROGRAM / DISPLAY "PGM" style=[just=l font_weight=demi_bold font_size=1.0];
DEFINE ACTIVITY / DISPLAY "ACTIVITY" style=[just=l font_weight=demi_bold font_size=1.0];
A sincere thank you to all who are willing to help eliminate my headache.
data reset;
if ( UPCASE("&title")='YES') then do;
if _n eq 1 then
flag = 0;
else flag = flag + 1;
if flag >= 11 then do;
pageit + 1;
flag = 0;
end;
set sortfile;
end;
else set sortfile;
run;
%macro OutToExcel;
%if ( "&title"='NO') %then %do;
Proc EXPORT Data = sortfile;
OUTFILE="c:\SAS\data\restrictedgifts.xls";
DBMS=excel2000;
REPLACE;
RUN;
%end;
%mend OutToExcel;
%OutToExcel;
RUN;
/*****************************************************************************************/
/* The next lines of code "set up" the report headers to be printed. Depending */
/* on whether the data is to be exported to Excel, the headers will either */
/* contain data or be blank. */
/*****************************************************************************************/
TITLE;
TITLE1 &title1;
TITLE2 &title2;
TITLE3 &title3;
FOOTNOTE;
FOOTNOTE1 &footnote1;
FOOTNOTE2 &footnote2;
OPTIONS noBYLINE;
OPTIONS orientation=landscape;
proc report data=sortfile spacing=1 style(Header)={font_size=1.0 font_weight=medium} split='*' missing;
/*****************************************************************************************/
/* The following code prints the data in a report format */
/*****************************************************************************************/
COLUMN ORGANIZATION_DESC FUND ORGANIZATION_CODE ACCOUNT PROGRAM ACTIVITY ACCOUNT_POOL ACCOUNT_TYPE_LEVEL_1
ACCOUNT_TYPE_DESC_1 PROGRAM_DESC ATTRIBUTE_TYPE ACCOUNT_DESC SUM_ADOPTED_BUDGET
SUM_BUDGET_ADJUSTMENTS SUM_ACCUMULATED_BUDGET SUM_BUDGET_RESERVATION SUM_ENCUMBRANCES
CURR_YEAR_TO_DATE_ACTIVITY SUM_YEAR_TO_DATE_ACTIVTY SUM_REMAINING_BALANCE;
DEFINE ORGANIZATION_DESC / DISPLAY "ORG DESC" style=[just=l font_weight=demi_bold font_size=1.0];
DEFINE FUND / DISPLAY "FUND" style=[just=l font_weight=demi_bold font_size=1.0];
DEFINE ORGANIZATION_CODE / DISPLAY "ORG CODE" style=[just=l font_weight=demi_bold font_size=1.0];
DEFINE ACCOUNT / DISPLAY "ACCT" style=[just=l font_weight=demi_bold font_size=1.0];
DEFINE PROGRAM / DISPLAY "PGM" style=[just=l font_weight=demi_bold font_size=1.0];
DEFINE ACTIVITY / DISPLAY "ACTIVITY" style=[just=l font_weight=demi_bold font_size=1.0];
A sincere thank you to all who are willing to help eliminate my headache.