0% found this document useful (0 votes)
185 views33 pages

Proc Report: Tim Hunter, SAS Institute Inc

Detailed exlanation about Proc report

Uploaded by

Sanjeev Kuridi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views33 pages

Proc Report: Tim Hunter, SAS Institute Inc

Detailed exlanation about Proc report

Uploaded by

Sanjeev Kuridi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

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.

Whats 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.

You might also like