SAS Example A10. Output Delivery System (ODS) Sample Data Set sales.txt. Examples of currently available ODS destinations: Mervyn Marasinghe

Similar documents
EXST SAS Lab Lab #6: More DATA STEP tasks

Basic Concepts #6: Introduction to Report Writing

Introducing a Colorful Proc Tabulate Ben Cochran, The Bedford Group, Raleigh, NC

Writing Reports with the

The REPORT Procedure CHAPTER 32

Using SAS to Analyze CYP-C Data: Introduction to Procedures. Overview

Introduction to SAS Procedures SAS Basics III. Susan J. Slaughter, Avocet Solutions

Introduction to SAS Procedures SAS Basics III. Susan J. Slaughter, Avocet Solutions

STAT:5400 Computing in Statistics

STAT 503 Fall Introduction to SAS

Processing SAS Data Sets

EXST3201 Mousefeed01 Page 1

Quick Results with the Output Delivery System

/* SAS Macro UNISTATS Version 2.2 December 2017

AMS Lab # 1. Prof. Wei Zhu

Analysis of variance and regression. November 13, 2007

Analysis of variance and regression. November 13, 2007

Part 1. Introduction. Chapter 1 Why Use ODS? 3. Chapter 2 ODS Basics 13

* Sample SAS program * Data set is from Dean and Voss (1999) Design and Analysis of * Experiments. Problem 3, page 129.

EXST SAS Lab Lab #8: More data step and t-tests

It s Proc Tabulate Jim, but not as we know it!

22S:166. Checking Values of Numeric Variables

The Essential Meaning of PROC MEANS: A Beginner's Guide to Summarizing Data Using SAS Software

Cluster Randomization Create Cluster Means Dataset

Chapters 18, 19, 20 Solutions. Page 1 of 14. Demographics from COLLEGE Data Set

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS

PLS205 Lab 1 January 9, Laboratory Topics 1 & 2

5b. Descriptive Statistics - Part II

SAS is the most widely installed analytical tool on mainframes. I don t know the situation for midrange and PCs. My Focus for SAS Tools Here

The STANDARD Procedure

THE UNIVERSITY OF BRITISH COLUMBIA FORESTRY 430 and 533. Time: 50 minutes 40 Marks FRST Marks FRST 533 (extra questions)

Getting Started with the Output Delivery System

Overview 14 Table Definitions and Style Definitions 16 Output Objects and Output Destinations 18 ODS References and Resources 20

I AlB 1 C 1 D ~~~ I I ; -j-----; ;--i--;--j- ;- j--; AlB

Statements with the Same Function in Multiple Procedures

Setting the Percentage in PROC TABULATE

SAS Instructions Entering the data and plotting survival curves

SAS Online Training: Course contents: Agenda:

SAS/STAT 14.1 User s Guide. Using the Output Delivery System

Reading data in SAS and Descriptive Statistics

Laboratory Topics 1 & 2

Introductory Guide to SAS:

SAS/STAT 15.1 User s Guide The STDIZE Procedure

Introductory SAS example

M'''~ ft\'''' PRot MEAAJS PROC. Pilot. P2.oc- ME AtJS. Ci+.\.,t.t\ {oy «(0""''" "OUS ) F~EQ. \keel. fo (OM p"te cbsty'.ptl\'t.

Print the Proc Report and Have It on My Desktop in the Morning! James T. Kardasis, J.T.K. & Associates, Skokie, IL

An Introduction to SAS University Edition

Lab #1: Introduction to Basic SAS Operations

Applied Regression Modeling: A Business Approach

SAS/STAT 14.2 User s Guide. The SURVEYIMPUTE Procedure

Getting Started with the SAS 9.4 Output Delivery System

Choosing the Right Procedure

INTRODUCTION SAS Prepared by A. B. Billings West Virginia University May 1999 (updated August 2006)

Beginning Tutorials. A Beginner's Guide to Incorporating SAS Output in Microsoft Office Applications Vincent DelGobbo, SAS Institute Inc.

Stata v 12 Illustration. First Session

Learning SAS by Example

Final Stat 302, March 17, 2014

Paper ODS, YES! Odious, NO! An Introduction to the SAS Output Delivery System

050 0 N 03 BECABCDDDBDBCDBDBCDADDBACACBCCBAACEDEDBACBECCDDCEA

Averages and Variation

Exercise #6: Sales by Item Year over Year Report

Using PROC TABULATE and ODS Style Options to Make Really Great Tables Wendi L. Wright, CTB / McGraw-Hill, Harrisburg, PA

Stata version 13. First Session. January I- Launching and Exiting Stata Launching Stata Exiting Stata..

I Launching and Exiting Stata. Stata will ask you if you would like to check for updates. Update now or later, your choice.

The MEANS/SUMMARY Procedure: Getting Started and Doing More

The FASTCLUS Procedure

Christopher Toppe, Ph.D. Computer Sciences Corporation

Getting Started with the SAS 9.4 Output Delivery System

The Essential Meaning of PROC MEANS: A Beginner's Guide to Summ~rizing Data Using SAS Software

Choosing the Right Procedure

Report Writing, SAS/GRAPH Creation, and Output Verification using SAS/ASSIST Matthew J. Becker, ST TPROBE, inc., Ann Arbor, MI

SAS/STAT 14.1 User s Guide. The FASTCLUS Procedure

Two useful macros to nudge SAS to serve you

Introduction to Stata Toy Program #1 Basic Descriptives

Contents of SAS Programming Techniques

STAT:5201 Applied Statistic II

THIS IS NOT REPRESNTATIVE OF CURRENT CLASS MATERIAL. STOR 455 Midterm 1 September 28, 2010

Christopher Louden University of Texas Health Science Center at San Antonio

SPSS. (Statistical Packages for the Social Sciences)

/********************************************/ /* Evaluating the PS distribution!!! */ /********************************************/

Eksamen ERN4110, 6/ VEDLEGG SPSS utskrifter til oppgavene (Av plasshensyn kan utskriftene være noe redigert)

9. Producing HTML output. GIORGIO RUSSOLILLO - Cours de prépara+on à la cer+fica+on SAS «Base Programming» 207

Chapter 5 INSET Statement. Chapter Table of Contents

Building and Updating MDDBs

SAS/STAT 13.1 User s Guide. The FASTCLUS Procedure

Tables for Two: An Introduction to the TABULATE Procedure

Introduction to STATA 6.0 ECONOMICS 626

PRACTICE EXERCISES. Family Utility Expenses

From An Introduction to SAS University Edition. Full book available for purchase here.

Going Beyond Proc Tabulate Jim Edgington, LabOne, Inc., Lenexa, KS Carole Lindblade, LabOne, Inc., Lenexa, KS

What Did You Learn? Key Terms. Key Concepts. 68 Chapter P Prerequisites

Multiple Graphical and Tabular Reports on One Page, Multiple Ways to Do It Niraj J Pandya, CT, USA

9. Producing HTML output. GIORGIO RUSSOLILLO - Cours de prépara+on à la cer+fica+on SAS «Base Programming» 208

SAS Institue EXAM A SAS Base Programming for SAS 9

B.2 Measures of Central Tendency and Dispersion

Stat 302 Statistical Software and Its Applications SAS: Data I/O

Getting Up to Speed with PROC REPORT Kimberly LeBouton, K.J.L. Computing, Rossmoor, CA

Example1D.1.sas. * Procedures : ; * 1. print to show the dataset. ;

Chapter 1. Looking at Data-Distribution

Paper S Data Presentation 101: An Analyst s Perspective

Transcription:

SAS Example A10 data sales infile U:\Documents\...\sales.txt input Region : $8. State $2. +1 Month monyy5. Headcnt Revenue Expenses format Month monyy5. Revenue dollar12.2 proc sort by Region State Month Mervyn Marasinghe proc print proc print label by Region State format Expenses dollar10.2 label State= State Month= Month Revenue= Sales Revenue Expenses= Overhead Expenses id Region State sum Revenue Expenses sumby Region title Sales report by State and Region 2 Sample Data Set sales.txt Output Delivery System (ODS) SOUTHERN FL JAN78 10 10000 8000 SOUTHERN FL FEB78 10 11000 8500 SOUTHERN FL MAR78 9 13500 9800 SOUTHERN GA JAN78 5 8000 2000 SOUTHERN GA FEB78 7 6000 1200 PLAINS NM MAR78 2 500 1350 NORTHERN MA MAR78 3 1000 1500 NORTHERN NY FEB78 4 2000 4000 NORTHERN NY MAR78 5 5000 6000 EASTERN NC JAN78 12 20000 9000 EASTERN NC FEB78 12 21000 8990 EASTERN NC MAR78 12 20500 9750 EASTERN VA JAN78 10 15000 7500 EASTERN VA FEB78 10 15500 7800 EASTERN VA MAR78 11 16600 8200 CENTRAL OH JAN78 13 21000 12000 CENTRAL OH FEB78 14 22000 13000 CENTRAL OH MAR78 14 22500 13200 CENTRAL MI JAN78 10 10000 8000 CENTRAL MI FEB78 9 11000 8200 CENTRAL MI MAR78 10 12000 8900 CENTRAL IL JAN78 4 6000 2000 CENTRAL IL FEB78 4 6100 2000 CENTRAL IL MAR78 4 6050 2100 ODS allows flexibility in presenting output from SAS procedures ODS can arrange output in more presentable ways It also can create output in a variety of formats (called destinations) Examples of currently available ODS destinations: LISTING: produces traditional monospace output PS or PDF: output that is formatted for a highresolution printer such as PostScript or PDF HTML: output that is formatted in various markup languages such as HTML RTF: output that is formatted for use with Microsoft Word Traditionally, results of a SAS procedure were displayed in a the output window in the LISTING format. Use the Results tab in the Preferences window to change HTML to LISTING format 3

Current Default Settings in SAS 9.3 The default destination in the SAS windowing environment is HTML (changed from traditional LISTING destination) The default style for the HTML destination is HTMLBlue This new style is an all-color style that is designed to integrate tables and modern statistical graphics In the past, SAS users used SAS/Graph to produce high quality graphics. We ll call these traditional SAS graphics. Template-based graphics produced by ODS Graphics (different from traditional SAS graphics) is now used for producing graphs is most SAS procs Previously, in the SAS Windowing environment, ODS GRAPHICS ON statement was used to enable (and ODS GRAPHICS OFF statement to disable) ODS Graphics SAS ODS Example 1 data oranges input Variety $ Flavor texture Looks Total=Flavor+Texture+Looks datalines navel 9 8 6 temple 7 7 7 valencia 8 9 9 mandarin 5 7 8 proc sort data=oranges by descending Total ods rtf file= U:\Documents\...\oranges.rtf" proc print data=oranges title 'Taste Test Results for Oranges' ods rtf close 6 PROC MEANS PROC MEANS options CLASS variables VAR variables TYPES request(s) WAYS list BY variables FREQ variable WEIGHT variable ID variables OUTPUT OUT=SAS_dataset statistics PROC MEANS (continued) Statistics: N, NMISS, MEAN, STD, MIN, MAX, RANGE, SUM, VAR, USS, CSS, CV, STDERR, T, PRT, SUMWGT Example of OUTPUT statement output out=stats mean=av_ht Av_Wt stderr=se_ht SE_Wt Options: DATA=, PRINT, MAXDEC=, FW=, MISSING, NWAY, IDMIN, DESCENDING, ORDER=, VARDEF=, statistics MAXDEC = n no. of decimal places (2) FW = n field width (12) For printing computed statistics ORDER=FREQ, DATA, INTERNAL, FORMATTED VARDEF=DF, N, WGT, WDF 7 8

SAS Example B5 data biology input Id Sex $ Age Year Height Weight datalines 7389 M 24 4 69.2 132.5 3945 F 19 2 58.5 112.0 4721 F 20 2 65.3 98.6 6327 M 20 1 70.2 135.4 8472 F 20 4 66.8 142.6 4875 M 20 1 74.2 160.4 proc means data=biology fw=8 maxdec=3 class Year Sex var Height Weight output out=stats mean=av_ht Av_Wt stderr=se_ht SE_Wt proc print data=stats title Biology Class Data Set: Output Statement PROC UNIVARIATE PROC UNIVARIATE options VAR variables CLASS variable-1 <(v-options)> < variable-2 <(v- options)> >...< / KEYLEVEL= value1 ( value1 value2 ) > BY variables ID variable OUTPUT < OUT=SAS-data-set > < keyword_1=names...keyword_k=names > < percentile-options > Some Options: DATA =, NOPRINT, PLOT, FREQ, NORMAL, ALPHA=, CIBASIC (TYPE= ALPHA=), MU0=, TRIM= (TYPE= ALPHA=), PCTLDEF=, VARDEF=, PCTLDEF=1,2,3,4 OR 5 (5 methods of computing percentiles) VARDEF=DF, N, WEIGHT, WDF (divisor for NORMAL computing variance) computes the Shapiro-Wilk statistic W if n 2000 or the Kolmogorov-Smirnov statistic D if n > 2000 10 PROC UNIVARIATE (continued) TYPE= LOWER, UPPER, TWOSIDED (specify type of confidence intervals) TRIM= list of integers or fractions specifying amount of trimming ALPHA=.05 (for both CIBASIC and TRIM specifications) Class Options: The v-options are MISSING or ORDER= ORDER = FREQ, DATA, INTERNAL, FORMATTED specifies how levels of the variable are ordered in the output Some Keywords for use with OUTPUT statement: N, NMISS, NOBS, MEAN, SUM, SD, VAR, SKEWNESS, KURTOSIS, SUMWGT, MAX, MIN, RANGE, Q3, MEDIAN, Q1, ORANGE, P1, P5, P10, P90, P95, P99, MODE, SIGNRANK, NORMAL, PCTLNAME=, PCTLPTS=, PCTLPRE= Example: proc univariate data=survey class county var acreage rainfall output out=new mean=ave1 ave2 var= var1 var2 SAS ODS Example 2 data biology input Id Sex $ Age Year Height Weight datalines 7389 M 24 4 69.2 132.5 3945 F 19 2 58.5 112.0 4721 F 20 2 65.3 98.6 6327 M 20 1 70.2 135.4 8472 F 20 4 66.8 142.6 4875 M 20 1 74.2 160.4 ods rtf file= U:\Documents\...\progB2_out.rtf" ods select BasicMeasures Quantiles TestsForNormality proc univariate data=biology Normal var Height title Biology class: Analysis of Height Distribution ods rtf close 11

SAS Example C12 (simplified) data rainfall input Control Seeded @@ Logseed = log10(seeded) label Logseed="Log of Seeded Rainfall" datalines 1202.6 2745.6 830.1 1697.8 372.4 1656.0 345.5 978.0 321.2 703.4 244.3 489.1 163.0 430.0 147.8 334.1 95.0 302.8 87.0 274.7 81.2 274.7 68.5 255.0 47.3 242.5 41.1 200.7 36.6 198.6 29.0 129.6 28.6 119.0 26.3 118.3 26.1 115.3 24.4 92.4 21.7 40.6 17.3 32.7 11.5 31.4 4.9 17.5 4.9 7.7 1.0 4.1 proc univariate data=rainfall var Logseed probplot Logseed/normal(mu=est sigma=est) PROC TABULATE PROC TABULATE options CLASS variable VAR variable FREQ variable WEIGHT variable BY variable TABLE expression, expression, / options KEYLABEL keyword= text Options: DATA=, MISSING, FORMAT=, ORDER=, FORMCHAR( ) =, NOSEPS, DEPTH= FORMAT = any valid SAS or user defined format (BEST12.2) ORDER = FREQ, DATA, INTERNAL,FORMATTED FORMCHAR= ---- + --- DEPTH = 10 14 PROC TABULATE (continued) PROC TABULATE (continued) TABLE statement TABLE expression 1, expression 2, expression 3 /options defines defines defines pages rows columns Expression consists of: Classification variables (CLASS variables) Analysis variables (variables in VAR) Statistics (N, MEAN, STD, MIN, MAX, etc.) Format specifications Other expressions Example Expressions: Assume we have the variables A,B,C,D,X and Y defined in SAS statements as follows: CLASS A B C D VAR X Y A*B A*B*C A*MEAN*X A B A B*C (A B)*C 15 Examples of TABLE statements. class variable TABLE PRODUCT,, SALETYPE*(QUANTITY AMOUNT) page expression row expression analysis variables column expression In the examples below, the required table format is specified with a TABLE statement and the output produced by different TABLE statements are sketched. The TABLE statement used appears on top of the table produced. 16

PROC TABULATE Examples First we will consider only three variables:, CITYSIZE, and POP where and CITYSIZE are CLASS variables and POP is an analysis variable (numerical, continuous-valued). Each observation in the data contains data for a single city for many cities in several regions. Variable CITYSIZE POP Description code for region of the country code for relative population size (S=small, M=medium, L=large) urban population Most applications like this need both CLASS and VAR statements in the PROC TABULATE step in addition to the TABLE statement: PROC TABULATE TITLE Population by Region CLASS VAR POP Examples of TABLE statement Example 1: TABLE,POP POP SUM NC 4650000.00 NE 6666000.00 SO 6864000.00 WE 8376000.00 Example 2: TABLE,CITYSIZE*POP *SUM CITYSIZE L M S POP POP POP SUM SUM SUM NC 3750000.00 750000.00 15000.00 NE 5022000.00 1422000.00 222000.00 SO 4488000.00 2088000.00 288000.00 WE 5592000.00 2592000.00 192000.00 17 18 Example 3: TABLE *CITYSIZE,POP*SUM POP SUM CITYSIZE NC L 3750000.00 M 750000.00 S 150000.00 NE L 5022000.00 M 1422000.00 S 222000.00 SO L 4488000.00 M 2088000.00 S 288000.00 WE L 5592000.00 M 2592000.00 S 192000.00 Example 4: TABLE *CITYSIZE*(SUM MEAN),POP CITYSIZE POP NC L SUM 3750000.00 MEAN 625000.00 M SUM 750000.00 MEAN 125000.00 S SUM 150000.00 MEAN 25000.00 NE L SUM 5022000.00 MEAN 837000.00 M SUM 1422000.00 MEAN 237000.00 S SUM 222000.00 MEAN 37000.00 SO L SUM 4488000.00 MEAN 748000.00 M SUM 2088000.00 MEAN 348000.00 S SUM 288000.00 MEAN 48000.00 WE 19 20

Next, add four additional variables to the example: PRODUCT and SALETYPE are class variables: QUANTITY and AMOUNT are analysis variables. Modified proc step: PROC TABULATE TITLE Sales by Region and City Size CLASS PRODUCT SALETYPE VAR POP QUANTITY AMOUNT The report produced by the following TABLE statement contains a separate table for each PRODUCT and provides an analysis of wholesale and retail sales by and by CITYSIZE. Example 5: TABLE PRODUCT, CITYSIZE,SALETYPE*(QUANTITY AMOUNT) PRODUCT A100 SALETYPE R W QUANTITY AMOUNT QUANTITY AMOUNT SUM SUM SUM SUM NC 1250.00 31250.00 1250.00 25000.00 NE 1600.00 40000.00 1600.00 32000.00 SO 1880.00 47000.00 1880.00 37600.00 WE 1840.00 46000.00 1840.00 36800.00 CITYSIZE L 3190.00 79750.00 3190.00 63800.00 M 2440.00 61000.00 2440.00 48800.00 S 940.00 23500.00 940.00 18800.00 PRODUCT A200 SALETYPE R W QUANTITY AMOUNT QUANTITY AMOUNT SUM SUM SUM SUM NC 1295.00 32375.00 1295.00 25900.00 21 22