Sample 25339: Customizing Output, Chapter 30
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.
These samples are from the "SAS Language and Procedures: Usage" book (No. 56075), Chapter 30.
For output and additional information on the samples refer to this book.
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: BUG30U01 */
/* TITLE: Customizing Output, Chapter 30 */
/* PRODUCT: BASE */
/* SYSTEM: ALL */
/* KEYS: DOC DATASTEP FILE PUT REPORT WRITING SET BY SUM */
/* NOTSORTED BY FIRST. LAST. HEADER LINESLEFT */
/* _PAGE_ FILENAME */
/* PROCS: */
/* DATA: */
/* */
/* SUPPORT: UPDATE: */
/* REF: SAS Language and Procedures: Usage */
/* MISC: Last step contains a FILE statement that must be */
/* edited to refer to a valid file name, or point to */
/* the PRINT file. */
/****************************************************************/
/* For simplicity the infile statement has been removed and */
/* the raw data is being read into this step via a cards */
/* statement. */
options pagesize=24;
title;
data circrep2;
input state $ morn even year;
cards;
Colorado 738.6 210.2 1984
Colorado 742.2 212.3 1985
Colorado 731.7 209.7 1986
Colorado 789.2 155.9 1987
Alaska 51.0 80.7 1984
Alaska 58.7 78.3 1985
Alaska 59.8 70.9 1986
Alaska 64.3 64.6 1987
Alabama 256.3 480.5 1984
Alabama 291.5 454.3 1985
Alabama 303.6 454.7 1986
Alabama . 454.5 1987
Maine . . 1984
Maine . 68.0 1985
Maine 222.7 68.6 1986
Maine 224.1 66.7 1987
run;
title 'Morning and Evening Newspaper Circulation';
title2;
title3
'State Year Thousands of Copies';
title4
' Morning Evening';
data _null_;
set circrep2;
by state notsorted;
file print;
if first.state then
do;
mtot=0;
etot=0;
put / @7 state @;
end;
put @26 year @53 morn 5.1 @66 even 5.1;
mtot+morn;
etot+even;
if last.state then
do;
alltot=mtot+etot;
put @52 '------' @65 '------' /
@26 'Total for each category'
@52 mtot 6.1 @65 etot 6.1 /
@35 'Combined total' @59 alltot 6.1;
end;
run;
options pagesize=24;
data _null_;
set circrep2;
by state notsorted;
file print notitles header=pagetop;
if first.state then
do;
mtot=0;
etot=0;
put / @7 state @;
end;
put @26 year @53 morn 5.1 @66 even 5.1;
mtot+morn;
etot+even;
if last.state then
do;
alltot=mtot+etot;
put @52 '------' @65 '------' /
@26 'Total for each category'
@52 mtot 6.1 @65 etot 6.1 /
@35 'Combined total' @59 alltot 6.1;
end;
return;
pagetop:
put @16 'Morning and Evening Newspaper Circulation' //
@7 'State' @26 'Year' @51 'Thousands of Copies' /
@51 'Morning Evening' ;
return;
run;
options pagesize=24;
data _null_;
set circrep2;
by state notsorted;
file print notitles header=pagetop;
if first.state then
do;
mtot=0;
etot=0;
put / @7 state @;
end;
put @26 year @53 morn 5.1 @66 even 5.1;
mtot+morn;
etot+even;
if last.state then
do;
alltot=mtot+etot;
put @52 '------' @65 '------' /
@26 'Total for each category'
@52 mtot 6.1 @65 etot 6.1 /
@35 'Combined total' @59 alltot 6.1;
end;
return;
pagetop:
pagenum+1;
put @16 'Morning and Evening Newspaper Circulation'
@67 'Page ' pagenum //
@7 'State' @26 'Year' @51 'Thousands of Copies' /
@51 'Morning Evening' ;
return;
run;
options pagesize=24;
data _null_;
set circrep2;
by state notsorted;
file print notitles header=pagetop linesleft=cklines;
if first.state then
do;
mtot=0;
etot=0;
if cklines<8 then put _page_;
put / @7 state @;
end;
put @26 year @53 morn 5.1 @66 even 5.1;
mtot+morn;
etot+even;
if last.state then
do;
alltot=mtot+etot;
put @52 '------' @65 '------' /
@26 'Total for each category'
@52 mtot 6.1 @65 etot 6.1 /
@35 'Combined total' @59 alltot 6.1;
end;
return;
pagetop:
pagenum+1;
put @16 'Morning and Evening Newspaper Circulation'
@67 'Page ' pagenum //
@7 'State' @26 'Year' @51 'Thousands of Copies' /
@51 'Morning Evening';
return;
run;
/* A filename statement must be issued associating an external */
/* file with the fileref bug30b. */
data _null_;
input state $ morn even year;
file BUG30B;
put @1 state @10 year @15 morn 5.1 @21 even 5.1;
cards;
Colorado 738.6 210.2 1984
Colorado 742.2 212.3 1985
Colorado 731.7 209.7 1986
Colorado 789.2 155.9 1987
Alaska 51.0 80.7 1984
Alaska 58.7 78.3 1985
Alaska 59.8 70.9 1986
Alaska 64.3 64.6 1987
Alabama 256.3 480.5 1984
Alabama 291.5 454.3 1985
Alabama 303.6 454.7 1986
Alabama . 454.5 1987
Maine . . 1984
Maine . 68.0 1985
Maine 222.7 68.6 1986
Maine 224.1 66.7 1987
run;
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.
These samples are from the "SAS Language and Procedures: Usage" book (No. 56075), Chapter 30. For output and additional information on the samples refer to this book. This chapter shows how report-writing techniques can be used to read/write data values in situations other than report production.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step Query and Reporting ==> Creating Reports ==> Non Graphical
|
| Date Modified: | 2005-12-08 11:34:44 |
| Date Created: | 2005-05-23 13:47:00 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |