May I know why the car2 report ‘Summary by model level’ not appear after the title, but start on the next page? Anyone can help? Thanks. DATA CAR; SET SASHELP.CARS; RUN; PROC SQL; CREATE TABLE CAR1 AS SELECT DISTINCT MAKE, SUM(INVOICE) AS INVOICE FROM CAR WHERE MAKE EQ 'BMW' GROUP BY MAKE ORDER BY MAKE; QUIT; PROC SQL; CREATE TABLE CAR2 AS SELECT DISTINCT MAKE, MODEL, TYPE, ORIGIN, INVOICE FROM CAR ORDER BY MAKE, MODEL; QUIT; DATA CAR2; SET CAR2 CAR2 CAR2 CAR2 CAR2; RUN; data _null_; set CAR1 end=eof; by MAKE; /* On the first member of the BY-Group, create a new macro variable VARn */ /* and increment the counter FLAG. */ if first.MAKE then do; flag+1; call symput('var'||put(flag,8. -L),MAKE); end; /* On the last observation of the data set, create a macro variable to */ /* contain the final value of FLAG. */ if eof then call symput('tot',put(flag,8. -L)); run; /* Create a macro to generate the new data sets. Dynamically produce data set names */ /* on the DATA statement, using subsetting criteria to create the new data sets */ /* based upon the value of the BY variable. */ %macro groups(dsn,byvar); %do i=1 %to &tot; data "_&&var&i"; set &dsn; if &byvar="&&var&i" then output; run; proc sql noprint; select distinct MAKE into :orderedvars2 separated by "" from CAR1 where MAKE eq "&&var&i"; quit; options nodate nonumber center; ods escapechar="^"; title; footnote; /* Create a data set containing the desired title text */ data test; text="^nCar Maker Summary Report - &orderedvars2^n&MTHWORD &YYYY"; run; %LET OUTPATH = D:\TEST\Incentive_ &YYYYMM-&orderedvars2..PDF; ODS PDF FILE="&OUTPATH" compress=9 startpage=NO; footnote1 j=c "Company Confidential"; *ods pdf text='^S={preimage="\\172.17.18.174\sas\_Common_\Images\saslogo.jpg"}'; ods pdf text="^20n"; /* Output the title text */ proc report data=test nowd noheader style(report)={rules=none frame=void} style(column)={font_weight=bold font_size=20pt just=c}; run; options nocenter; options orientation=landscape papersize=A3; *options orientation=portrait papersize=A3; ods pdf startpage=now; ods pdf style=analysis; TITLE "Car Maker -&Mthword &YYYY Summary"; ODS TEXT = "BRAND OVERALL SALES"; PROC PRINT DATA=CAR1(WHERE=(MAKE = "&&var&i")) NOOBS LABEL; LABEL MAKE="MODEL" INVOICE="PRICE"; RUN; ODS TEXT = " "; ODS TEXT = " "; ODS TEXT = "SUMMARY BY MODEL LEVEL"; PROC REPORT DATA=CAR2(WHERE=(MAKE = "&&var&i"))style(header)=[background=tan] NOWINDOWS HEADLINE HEADSKIP; COLUMNS MAKE MODEL TYPE ORIGIN INVOICE; DEFINE MAKE /GROUP 'Car Brand'; DEFINE MODEL / DISPLAY 'Car Model'; DEFINE TYPE / DISPLAY 'Type'; DEFINE ORIGIN / DISPLAY 'Origin'; DEFINE INVOICE / SUM 'Price' FORMAT=DOLLAR16.2; COMPUTE BEFORE MAKE; ENDCOMP; RBREAK AFTER/ SUMMARIZE; COMPUTE AFTER; MAKE = "TOTAL"; ENDCOMP; BREAK AFTER MAKE / SKIP SUMMARIZE DOL DUL; RUN; ODS PDF CLOSE; ODS LISTING; ODS LISTING CLOSE; %end; %mend groups; options mprint symbolgen; %groups(CAR1,MAKE)
... View more