Sample 24929: Generate page numbers on BY-group processed plots
This sample uses macro coding and a FOOTNOTE statement to generate page numbers on a BY-group plot with PROC GPLOT.
While this sample code produces a total of three graphs, the Results tab only displays the third graph.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample uses macro coding and a FOOTNOTE statement to generate page numbers on a BY-group plot with PROC GPLOT.
The graphics output in the Results tab was produced using SASĀ® 9.2. Submitting the sample code with releases of SAS prior to SAS 9.2 might produce different results.
While this sample code produces a total of three graphs, the Results tab only displays the third graph.
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
/* Specify macro debugging options */
options mprint mlogic symbolgen;
/* Create sample data set ONE */
data one;
do bgrp='A','B','C';
do XVAR=1 to 10;
YVAR=ranuni(0);
output;
end;
end;
run;
/* Sort data set ONE by BGRP variable */
proc sort;
by bgrp;
run;
/* Create macro variables that resolve to page number. */
/* Create macro variables that resolve to BGRP values. */
/* Create a macro variable that resolves to total number of GPLOTs/pages. */
data _null_;
set one end=eof;
by bgrp;
if first.bgrp then count+1;
call symput('pg'||left(count),trim(left(count)));
call symput('grp'||left(count),trim(left(bgrp)));
if eof then
call symput('total',trim(left(count)));
run;
/* Create macro GPLOT. */
/* Specify a macro %DO loop with a subsetting WHERE statement */
/* to simulate BY-group processing and permit the macro variables */
/* to resolve. */
%macro gplot;
proc gplot data=one;
%do i=1 %to &total;
footnote1 j=r "Page &&pg&i of &total";
footnote2 ' ';
footnote3 angle=90 ' ';
title2 "BGRP: &&grp&i";
plot yvar*xvar;
where bgrp="&&grp&i";
run;
%end;
quit;
%mend gplot;
/* Specify SYMBOL statement */
symbol1 value=dot interpol=join color=vibg height=1.3;
/* Add a title to the graph */
title1 'Add Page Numbers to Graphics Output';
/* Invoke the GPLOT macro */
%gplot
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample uses macro coding and a FOOTNOTE statement to generate page numbers on a BY-group plot with PROC GPLOT.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Plots ==> Line
|
Date Modified: | 2005-08-31 03:03:19 |
Date Created: | 2004-11-11 11:08:02 |
Operating System and Release Information
SAS System | SAS/GRAPH | All | n/a | n/a |