PROC REPORT

advertisement
PROC REPORT
Tim Hunter, SAS Institute Inc.
Copyright © 2006, SAS Institute Inc. All rights reserved.
ƒ Intro
ƒ PROC REPORT Basics
ƒ ODS and PROC REPORT
ƒ New in PROC REPORT for 9.2
ƒ Questions?
Copyright © 2006, SAS Institute Inc. All rights reserved.
Copyright © 2006, SAS Institute Inc. All rights reserved.
title "Basic PROC REPORT Report";
proc report data=sashelp.class;
run;
Copyright © 2006, SAS Institute Inc. All rights reserved.
The COLUMN statement
ƒ Specifies the column order
ƒ Defines spanning headers
proc report data=sashelp.class;
column ('data=sashelp.class' sex age name
('Measurements' height weight));
run;
Copyright © 2006, SAS Institute Inc. All rights reserved.
The DEFINE statement
ƒ Usually one for each column in the report
ƒ Controls the appearance of the column
ƒ Specifies how a variable is used in the report
proc report data=sashelp.class;
column column1 column2 column3 …;
define column1 / options;
define column2 / options;
Copyright © 2006, SAS Institute Inc. All rights reserved.
Variable usage
ƒ DISPLAY – the default
ƒ ORDER – sort the rows
ƒ GROUP – consolidate observations into groups
ƒ ANALYSIS – calculate a statistic
ƒ COMPUTED – computed by PROC REPORT
ƒ ACROSS – class variables in the column
dimension
Copyright © 2006, SAS Institute Inc. All rights reserved.
ORDER Variables
ƒ Order the rows
proc report data=class;
column sex age name
('Measurements' height weight);
define sex--age / order;
define name--weight / display;
run;
Copyright © 2006, SAS Institute Inc. All rights reserved.
GROUP Variables
ƒ Consolidate multiple observations
proc report data=sashelp.class;
column age sex n;
define age / group;
define sex / group;
define N / 'N' format=2.;
run;
Copyright © 2006, SAS Institute Inc. All rights reserved.
ANALYSIS Variables
ƒ Calculate a statistic for the group of observations
represented by a cell in the report
proc report data=sashelp.class;
column age sex n height weight;
define sex / group;
define age / group;
define n / 'N' format=2.;
define height / analysis mean 'Mean Weight' format=6.1;
define weight / analysis mean 'Mean Height' format=6.2;
run;
Copyright © 2006, SAS Institute Inc. All rights reserved.
Copyright © 2006, SAS Institute Inc. All rights reserved.
ACROSS Variables
ƒ A column for each value of
the variable
proc report data=sashelp.class;
column age N sex,weight,Mean;
define age / group;
define N / 'Count';
define sex / across;
define weight / analysis;
run;
Copyright © 2006, SAS Institute Inc. All rights reserved.
The BREAK Statement
ƒ Introduces a summary row
ƒ Associated with a location in the report
proc report data=sashelp.class;
column sex age height weight;
define sex / order;
break after sex / summarize page;
run;
Copyright © 2006, SAS Institute Inc. All rights reserved.
Copyright © 2006, SAS Institute Inc. All rights reserved.
The COMPUTE Statement
ƒ Denotes a group of statements that PROC
REPORT executes as it builds the report.
ƒ Computes the value of a variable
ƒ Inserts custom text
ƒ Adds ODS style attributes or hyperlinks
Copyright © 2006, SAS Institute Inc. All rights reserved.
COMPUTED Variables
define height--weight / display noprint;
define mheight / computed format=6.2 'Height (cm)';
define mweight / computed format=5.2 'Weight (kg)';
compute mheight;
mheight = height * 2.54;
endcomp;
compute mweight;
mweight = weight * 0.4536;
endcomp;
Copyright © 2006, SAS Institute Inc. All rights reserved.
Copyright © 2006, SAS Institute Inc. All rights reserved.
LINE statement, DEFINE routine
compute before age / style={background=#bcd3ab};
agew = propcase(trim(put(age, words.)));
line agew $8. ' year olds';
endcomp;
compute name;
if sex = 'F' then
call define(_col_, 'url', 'http://test.com/results/girls/' || trim(name) || '.html' );
else
call define(_col_, 'url', 'http://test.com/results/boys/' || trim(name) || '.html' );
endcomp;
Copyright © 2006, SAS Institute Inc. All rights reserved.
Copyright © 2006, SAS Institute Inc. All rights reserved.
ODS and PROC REPORT
ƒ Monospace vs. markup
ƒ STYLE options
ƒ Other forms of output
Copyright © 2006, SAS Institute Inc. All rights reserved.
Copyright © 2006, SAS Institute Inc. All rights reserved.
"","Sex",,,
"","Sex",,,
"","Female",,"Male",
"","Female",,"Male",
"","Weight",,"Weight",
"","Weight",,"Weight",
"Age","Count","Mean","Count","Mean"
"Age","Count","Mean","Count","Mean"
11,1,50.5,1,85
11,1,50.5,1,85
12,2,80.75,3,103.5
12,2,80.75,3,103.5
13,2,91,1,84
13,2,91,1,84
14,2,96.25,2,107.5
14,2,96.25,2,107.5
15,2,112.25,2,122.5
15,2,112.25,2,122.5
16,".",".",1,150
16,".",".",1,150
Copyright © 2006, SAS Institute Inc. All rights reserved.
STYLE= option
ƒ Customizes fonts, colors, image, etc.
ƒ Can customize the entire report, just the
headers, individual columns, individual rows
ƒ Can also customize LINE statement output,
summary lines
Copyright © 2006, SAS Institute Inc. All rights reserved.
Alternating background colors
compute name;
bg + 1;
if mod(bg, 2) = 1 then
call define(_row_, "style", "style={background=white}");
else
call define(_row_, "style", "style={background=#d1e9d1}");
endcomp;
Copyright © 2006, SAS Institute Inc. All rights reserved.
Copyright © 2006, SAS Institute Inc. All rights reserved.
What’s new in 9.2?
ƒ New ODS destinations
ƒ SPANROWS option
ƒ New table of contents
Copyright © 2006, SAS Institute Inc. All rights reserved.
Copyright © 2006, SAS Institute Inc. All rights reserved.
SPANROWS Option
Copyright © 2006, SAS Institute Inc. All rights reserved.
SPANROWS Option
Copyright © 2006, SAS Institute Inc. All rights reserved.
Better Table of Contents
Copyright © 2006, SAS Institute Inc. All rights reserved.
Copyright © 2006, SAS Institute Inc. All rights reserved.
Where to go for more…
ƒ SAS OnlineDoc
http://support.sas.com/documentation/onlinedoc/
sas9doc.html
ƒ Carpenter's Complete Guide to the SAS REPORT
Procedure, Art Carpenter, at the SAS Bookstore
http://www.sas.com/apps/pubscat/welcome.jsp
ƒ ODS is part of the Base SAS community
http://support.sas.com/rnd/base/index-ods-resources.html
ƒ Output Delivery System: The Basics, Lauren Hayworth,
also at the SAS Bookstore
Copyright © 2006, SAS Institute Inc. All rights reserved.
Copyright © 2006, SAS Institute Inc. All rights reserved.
Download