

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 3
This page cannot be seen from the preview
Don't miss anything!


3
from http://ftp.sas.com/techsup/download/sample/base/tabulate/tabformat_classva
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 ;
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:
|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|