Proc Tabulate: Displaying Descriptive Statistics in Tabular Format using SAS - Prof. Mary , Study notes of Statistics

An introduction to proc tabulate, a sas procedure used to display descriptive statistics in tabular format. Proc tabulate offers flexibility in classifying values of variables and establishing a hierarchical relationship between them. It also allows users to format variables and customize the appearance of procedure-generated statistics.

Typology: Study notes

Pre 2010

Uploaded on 03/11/2009

koofers-user-bx4-1
koofers-user-bx4-1 🇺🇸

5

(1)

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
22S:166
Computing in Statistics
Proc tabulate
Lecture 19
Nov. 12, 2070
Kate Cowles
374 SH, 335-0727
2
Proc tabulate
displays descriptive statistics in tabular for-
mat
can create variety of tables ranging from sim-
ple to complex and highly customized
computes many of same statistics reported
from proc means and proc freq
flexibility in classifying values of variables and
establishing a hierarchical relationship between
variables
mechanism for labeling and formatting vari-
ables and procedure- generated statistics
3
Example 1
from
http://ftp.sas.com/techsup/download/sample/base/tabulate/tabformat_classva
PROC TABULATE Sample
--------------------
USAGE: User would like to format the CLASS varia bles and ANALYSIS
variables.
METHOD: Use a FORMA T statement to format the CLASS variables. Use
the format modifier on the TABLE statement to f ormat the
analysis variables.
DATE CREATED: 2-19-97
4
SAMPLE CODE:
data sales;
input name $ region $ product $ sales;
cards;
SMITH A CANDY 22000.
SMITH A CHIPS 10000.
JONES A CANDY 25000.
JONES A CHIPS 5000.
JOHNSON B CANDY 12000.
JOHNSON B CHIPS 15000.
ADAMS B CANDY 10000.
ADAMS B CHIPS 8000.
;
proc format; /* Create user-defined format */
value $fmtx ’A’=’CARY’
’B’=’RALEIGH’;
proc tabulate data=sales;
/*-----------------------------------------------------*/
/* Use FORMAT stmt. to assign format to CLASS variable */
/* Use *F= to assign a format to an ANALYSIS variable */
/*-----------------------------------------------------*/
format region $fmtx.;
class name region;
var sales;
table region*name, sales*(sum n)*f=comma8.;
run
;
pf3

Partial preview of the text

Download Proc Tabulate: Displaying Descriptive Statistics in Tabular Format using SAS - Prof. Mary and more Study notes Statistics in PDF only on Docsity!

22S:

Computing in Statistics

Proc tabulate

Lecture 19

Nov. 12, 2070

Kate Cowles

374 SH, 335-

[email protected]

Proc tabulate

• displays descriptive statistics in tabular for-

mat

• can create variety of tables ranging from sim-

ple to complex and highly customized

• computes many of same statistics reported

from proc means and proc freq

• flexibility in classifying values of variables and

establishing a hierarchical relationship between

variables

• mechanism for labeling and formatting vari-

ables and procedure- generated statistics

3

Example 1

from http://ftp.sas.com/techsup/download/sample/base/tabulate/tabformat_classva

PROC TABULATE Sample

USAGE: User would like to format the CLASS variables and ANALYSIS variables.

METHOD: Use a FORMAT statement to format the CLASS variables. Use the format modifier on the TABLE statement to format the analysis variables.

DATE CREATED: 2-19-

4

SAMPLE CODE:

data sales; input name $ region $ product $ sales; cards; SMITH A CANDY 22000. SMITH A CHIPS 10000. JONES A CANDY 25000. JONES A CHIPS 5000. JOHNSON B CANDY 12000. JOHNSON B CHIPS 15000. ADAMS B CANDY 10000. ADAMS B CHIPS 8000. ;

proc format; /* Create user-defined format */ value $fmtx ’A’=’CARY’ ’B’=’RALEIGH’;

proc tabulate data=sales; /-----------------------------------------------------/ /* Use FORMAT stmt. to assign format to CLASS variable / / Use F= to assign a format to an ANALYSIS variable / /-----------------------------------------------------/ format region $fmtx.; class name region; var sales; table regionname, sales(sum n)*f=comma8.; run ;

SAMPLE OUTPUT:

| | SALES |

| | SUM | N |

|REGION |NAME | | |

|CARY |JONES | 30,000| 2|

| |SMITH | 32,000| 2|

|RALEIGH |ADAMS | 18,000| 2|

| |JOHNSON | 27,000| 2|

Example 2

PROC TABULATE Sample

USAGE: User has data derived from a multiple choice questionarie. They would like to get frequency counts of the response for each question.

METHOD: Manipulate the data so that TABULATE receives one CLASS variable for reponses instead of four. Also, create a new answer variable. Place both variables on the CLASS statement.

DATE CREATED: 2-19-

7

SAMPLE CODE:

data old; input q1 $ q2 $ q3 $ q4 $; cards; A B C D E F A E C B B A B A D E E F A B A A A C F E A E ;

data new; set old; q=’Question 1’; ans=q1; output; q=’Question 2’; ans=q2; output; q=’Question 3’; ans=q3; output; q=’Question 4’; ans=q4; output; drop q1-q4; run;

proc tabulate data=new format=1.0; class q ans; table q=’ ’, ans=’CHOICES’*n=’ ’ / misstext=’0’; run;

8

SAMPLE OUTPUT:

| | CHOICES |

| |A|B|C|D|E|F|

|Question 1 |2|1|1|0|2|1| |-----------------------------+-+-+-+-+-+-| |Question 2 |2|2|0|0|1|2| |-----------------------------+-+-+-+-+-+-| |Question 3 |4|1|1|1|0|0| |-----------------------------+-+-+-+-+-+-| |Question 4 |1|1|1|1|3|0|