/* Richard A. DeVenezia * www.devenezia.com * 11/3/2003 * * Generate a report containing a tabulate and graph */ data foo; do region = 'A', 'B'; do date = '01jan02'd to '31dec02'd; do salesmanId = 1 to 10; sales = int ( 100 * ranuni(0)) ; if region = 'A' then sales = sales*2; if ranuni(0) < 0.45 then continue; output; end; end; end; label salesmanId = 'Salesman Id' region = 'Region' ; run; %*--------------------------------------------------------------------; %let iterate = -%sysfunc(datetime()); %let iterate = ; %let outfile = "%sysfunc(pathname(work))/report&iterate..pdf"; %let outfile = "\\extreme\samples\ods-tabulate-with-graph-report&iterate..pdf"; ods listing close; ods pdf file=&outfile startpage=never ; options nodate nonumber; options topmargin=(0.6in); goptions reset=all device=pdf ftext='Helvetica'; */*; title; footnote; title f='Arial' "Sales 2002"; proc tabulate data=foo style={font_face=Helvetica}; class date region salesmanid / style={font_face=Helvetica}; classlevel date region salesmanid / style={font_face=Helvetica}; keyword all / style={font_face=Helvetica}; var sales; table region * (date all) all, (salesmanid all) * sales='' * sum='' * f=comma12.; format date yyq4.; label date = 'Quarter'; run; title; goptions hsize=4in vsize=4.5in ; axis1 order=(0 to 6e4 by 1e4) label=('Sales') minor=(n=3); %let vbarOptions = discrete sumvar=sales subgroup=salesmanid nolegend raxis=axis1 width=6; goptions horigin=0in vorigin=0.5in; proc gchart data=foo; by region; where region = 'A'; vbar date / &vbarOptions; format date yyq4.; label date='Quarter'; run; goptions horigin=4in vorigin=0.5in; proc gchart data=foo; by region; where region = 'B'; vbar date / &vbarOptions; format date yyq4.; label date='Quarter'; run; quit; * /; %*--------------------------------------------------------------------; ods pdf startpage=now; title f='Arial' "Sales 2002"; proc tabulate data=foo style={font_face=Helvetica}; class date region salesmanid / style={font_face=Helvetica background=cx6699CC}; classlevel date region salesmanid / style={font_face=Helvetica background=cx77AADD}; keyword all / style={font_face=Helvetica background=cx6699CC}; var sales; table region * (date all) all, (salesmanid all) * sales='' * sum='' * f=comma12. / box=[style={background=cx6699CC}]; ; format date yyq4.; label date = 'Quarter'; run; title; proc sql; create view foo2 as select intnx ('month', date, 0) as month format=yymon5. , intck ('month', intnx('qtr', date, 0), date) + 1 as monthInQtr format=2. , * from foo ; quit; goptions horigin=0in vorigin=3.1in hsize=7.9in vsize=2.5in htext=8pt hby=0; %let vbarOptions = discrete group=date subgroup=monthInQtr sumvar=sales space=0 coutline=black; pattern1 color=cx5588BB; pattern2 color=cx6699CC; pattern3 color=cx77AADD; proc gchart data=foo2; title move=(50,90)pct "#byvar1 #byval1"; by region; where region = 'A'; vbar salesmanid / &vbarOptions nolegend; format date yyq4.; label date='Quarter'; run; goptions horigin=0in vorigin=0.1in hsize=7.9in vsize=3in htext=8pt; legend1 across=3 ; proc gchart data=foo2; by region; where region = 'B'; vbar salesmanid / &vbarOptions legend; format date yyq4.; label date='Quarter'; label monthInQtr = 'Month in quarter'; run; quit; ods pdf close; ods listing;