Procedure features: |
TABLE statement:
|
denominator definition (angle bracket operators) |
|
N statistic |
|
PCTN
statistic |
|
variable list | |
|
Other features: |
FORMAT procedure |
SAS system options:
|
SYMPUT
routine |
|
The two tables in this example show
The reports appear on one physical page with only one page
number. By default, they would appear on separate pages.
In addition to showing how to create these tables, this
example shows how to
-
use a DATA step to count the number of observations
in a data set
-
store that value in a macro variable
-
access that value later in the SAS
session.
The following figure shows the survey form that is used
to collect data.
Completed Survey Form
![[Completed Survey Form]](images/customerquestionnaire.gif)
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
options nodate pageno=1 linesize=80 pagesize=18 formdlim=' '; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
data customer_response;
input Customer Factor1-Factor4 Source1-Source3
Quality1-Quality3;
datalines;
1 . . 1 1 1 1 . 1 . .
2 1 1 . 1 1 1 . 1 1 .
3 . . 1 1 1 1 . . . .
. . . more data lines . . .
119 . . . 1 . . . 1 . .
120 1 1 . 1 . . . . 1 .
; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
data _null_;
if 0 then set customer_response nobs=count;
call symput('num',left(put(count,4.)));
stop;
run; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
proc format;
picture pctfmt low-high='009.9 %';
run; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
proc tabulate data=customer_response; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
var factor1-factor4 customer; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
table factor1='Cost'
factor2='Performance'
factor3='Reliability'
factor4='Sales Staff',
(n='Count'*f=7. pctn<customer>='Percent'*f=pctfmt9.) ; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
title 'Customer Survey Results: Spring 1996';
title3 'Factors Influencing the Decision to Buy';
run; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
options nonumber; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
proc tabulate data=customer_response; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
var source1-source3 customer; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
table source1='TV/Radio'
source2='Newspaper'
source3='Word of Mouth',
(n='Count'*f=7. pctn<customer>='Percent'*f=pctfmt9.) ; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
title 'Source of Company Name';
footnote "Number of Respondents: &num";
run; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
options formdlim='' number; |
Customer Survey Results: Spring 1996 1
Factors Influencing the Decision to Buy
--------------------------------------
| | Count | Percent |
|------------------+-------+---------|
|Cost | 87| 72.5 %|
|------------------+-------+---------|
|Performance | 62| 51.6 %|
|------------------+-------+---------|
|Reliability | 30| 25.0 %|
|------------------+-------+---------|
|Sales Staff | 120| 100.0 %|
--------------------------------------
Source of Company Name
--------------------------------------
| | Count | Percent |
|------------------+-------+---------|
|TV/Radio | 92| 76.6 %|
|------------------+-------+---------|
|Newspaper | 69| 57.5 %|
|------------------+-------+---------|
|Word of Mouth | 26| 21.6 %|
--------------------------------------
Number of Respondents: 120
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.