Patrick Thornton SRI International.  Example of a Multiple Response Item ◦ Variable coding and example data  A Cross Tabulation using Proc REPORT 

Slides:



Advertisements
Similar presentations
Haas MFE SAS Workshop Lecture 3:
Advertisements

DIVERSE REPORT GENERATION By Chris Speck PAREXEL International Durham, NC.
Examples from SAS Functions by Example Ron Cody
Outline Proc Report Tricks Kelley Weston. Outline Examples 1.Text that spans columnsText that spans columns 2.Patient-level detail in the titlesPatient-level.
Dr. Yang, Qingxiong (with slides borrowed from Dr. Yuen, Joe) LT4: Control Flow - Loop CS2311 Computer Programming.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Quick Data Summaries in SAS Start by bringing in data –Use permanent data set for these examples Proc Tabulate –Produces summaries very quickly and easily.
A Simple Guide to Using SPSS© for Windows
Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace Washington State University.
Introduction to SQL Session 1 Retrieving Data From a Single Table.
PROC SQL – Select Codes To Master For Power Programming Codes and Examples from SAS.com Nethra Sambamoorthi, PhD Northwestern University Master of Science.
Let SAS Do the Coding for You! Robert Williams Business Info Analyst Sr. WellPoint Inc.
How to Build Tabular Dashboards Using Proc Report
Data Cleaning 101 Ron Cody, Ed.D Robert Wood Johnson Medical School Piscataway, NJ.
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
Organizing Your Data for Statistical Analysis in SPSS
Chapter 10:Processing Macro Variables at Execution Time 1 STAT 541 © Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Chapter 8 Producing Summary Reports. Section 8.1 Introduction to Summary Reports.
A Concise Display of Multiple Response Items Patrick Thornton.
SAS PROC REPORT PROC TABULATE
Chapter 9 Producing Descriptive Statistics PROC MEANS; Summarize descriptive statistics for continuous numeric variables. PROC FREQ; Summarize frequency.
PROC REPORT organizes the output in many ways, from the simple to highly complex… PROC REPORT NOWINDOWS HEADLINE HEADSKIP; COLUMN variable-list; DEFINE.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.
Multiple Uses for a Simple SQL Procedure Rebecca Larsen University of South Florida.
SAS Macro: Some Tips for Debugging Stat St. Paul’s Hospital April 2, 2007.
Copyright © 2004, SAS Institute Inc. All rights reserved. SAS is a registered trademark or trademark of SAS Institute Inc. in the USA and other countries.
Essential ODS PDF Patrick Thornton.
Part 4 Syntax or point-and-click?. British Social Attitudes 1986 Q.114, page 43b.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
1 Efficient SAS Coding with Proc SQL When Proc SQL is Easier than Traditional SAS Approaches Mike Atkinson, May 4, 2005.
Copyright © Nancy Acemian 2004 For Loops-Break-Continue COMP For loop is a counter controlled loop. For loop is a pretest loop. Used when number.
1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® Excel 2010 © 2011 The McGraw-Hill Companies,
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
XP. Objectives Sort data and filter data Summarize an Excel table Insert subtotals into a range of data Outline buttons to show or hide details Create.
Priya Ramaswami Janssen R&D US. Advantages of PROC REPORT -Very powerful -Perform lists, subsets, statistics, computations, formatting within one procedure.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
Creating and Using Custom Formats for Data Manipulation and Summarization Presented by John Schmitz, Ph.D. Schmitz Analytic Solutions, LLC Certified Advanced.
Chapter 4 concerns various SAS procedures (PROCs). Every PROC operates on: –the most recently created dataset –all the observations –all the appropriate.
YET ANOTHER TIPS, TRICKS, TRAPS, TECHNIQUES PRESENTATION: A Random Selection of What I Learned From 15+ Years of SAS Programming John Pirnat Kaiser Permanente.
DTC Quantitative Methods Summary of some SPSS commands Weeks 1 & 2, January 2012.
Microsoft® Excel Create an Excel table. 1 Work with the Table Tools Design tab. 2 Sort and filter records in a table. 3 Identify structured references.
Computing with SAS Software A SAS program consists of SAS statements. 1. The DATA step consists of SAS statements that define your data and create a SAS.
FORMAT statements can be used to change the look of your output –if FORMAT is in the DATA step, then the formats are permanent and stored with the dataset.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
1 Chapter 3: Getting Started with Tasks 3.1 Introduction to Task Dialogs 3.2 Creating a Listing Report 3.3 Creating a Frequency Report 3.4 Creating a Two-Way.
Excel part 5 Working with Excel Tables, PivotTables, and PivotCharts.
BMTRY 789 Lecture9: Proc Tabulate Readings – Chapter 11 & Selected SUGI Reading Lab Problems , 11.2 Homework Due Next Week– HW6.
Chapter 6: Modifying and Combining Data Sets  The SET statement is a powerful statement in the DATA step DATA newdatasetname; SET olddatasetname;.. run;
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 16 & 17 By Tasha Chapman, Oregon Health Authority.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
Session 1 Retrieving Data From a Single Table
Some Assignments  Write a program which prints the following information about at least 5 persons: NAME MAIL-ID EMPLOYEE-CODE PHONE Eg. Umesh
Applied Business Forecasting and Regression Analysis
Loops BIS1523 – Lecture 10.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Chapter 6: Modifying and Combining Data Sets
Chapter 11 Chi-Square Tests.
Creating Macro Variables in SQL (Review)
Instructor: Raul Cruz-Cano
Lesson 8 - Topics Creating SAS datasets from procedures
Retrieving Macro Variables in the DATA Step
Examining model stability, an example
Chapter 11 Chi-Square Tests.
Never Cut and Paste Again
Producing Descriptive Statistics
Loops and Arrays in JavaScript
Chapter 11 Chi-Square Tests.
Introduction to SAS Essentials Mastering SAS for Data Analytics
Presentation transcript:

Patrick Thornton SRI International

 Example of a Multiple Response Item ◦ Variable coding and example data  A Cross Tabulation using Proc REPORT  Examine the Proc REPORT Syntax for: ◦ Grouping and counting observations ◦ Creating a summary row ◦ Adding a ‘Total’ label to the summary row ◦ Creating a count and percent ◦ Summing columns 2

 Respondents may leave blank those service categories they did not receive  Respondents may not provide a response to any of the service categories 3

Referral One:  Number of children receiving at least one service  Number of children receiving each service (e.g. CHI)  Percent of children receiving each service (e.g. HV)  Number of total services Total:  Children receiving at least one service  Children and percent of children receiving each service  Number of total services 4

proc report data=md  nowd missing;  col referral n;  define referral /group center;  define n /’Children’ center;  where CHI ne. or HV ne. or TS ne. ; run;  NOWD prevents the interactive window and MISSING includes OBS missing REFERRAL  COL determines the order of columns, REFERRAL and N where N is a key word to obtain the count of observations  DEFINE with the /GROUP option is used to obtain the distinct values of REFERRAL  DEFINE N is used to label and center the column  WHERE removes OBS missing on all service variables 5

proc report data=work.multir missing nowd; col referral n; define referral /group; define n /’Children’ center;  rbreak after / summarize; Run;  Creates total number of children (OBS) 6

proc report data=work.multir missing nowd out=d; col referral n; define referral /group; define n /’Children’ center; rbreak after / summarize; run; Proc print data=d noobs; run; 7

col referral  newcol n; define referral /group  noprint; define n /’Children’ center;  define newcol/computed ‘Referral’;  compute newcol /char length=15;  if _BREAK_="_RBREAK_" then newcol = 'Total'; else newcol = put(referral,myrows.); endcomp; rbreak after / summarize;  Adds NEWCOL, a computed variable not in the data set  Hides the REFERRAL variable  Defines NEWCOL as COMPUTED  Start a compute block, NEWCOL as a 15 length character variable  Test _BREAK_ for summary row and set NEWCOL to “Total,” otherwise set to formatted value of REFERRAL. 8

col referral newcol n  CHI  PCHI; define referral /group noprint; define n / ‘Children’ center;  define CHI / analysis ‘CHI’ sum format=5.0 center;  define PCHI /computed ‘%CHI’ format=percent8.1 center ;  compute PCHI; PCHI = CHI.sum/n; endcomp;   CHI is a column and defined as a SUM   PCHI is a column and defined as COMPUTED  PCHI is COMPUTED as CHI.SUM / n Repeat for each Service 9

col referral newcol n  CHI PCHI HV PHV TS PTS total;  define total/computed "Services" width=10 center; compute total;  total = sum(chi.sum, hv.sum,ts.sum); endcomp;  As shown on previous slide, service sums and computed percents. Total column is added.  Total is defined as COMPUTED  Total is sum of the sums of each service variable 10

proc report data=work.multir missing nowd ; col referral newcol n CHI p1 HV p2 TS p3 total; define referral /group left width=15 noprint; define newcol /computed "Referral" ; define n/format=8.0 "Children" center; define CHI / analysis sum "CHI" format=5.0 center; define HV / analysis sum "HV" format=5.0 center; define TS / analysis sum "TS" format=5.0 center; define p1 /computed "%" format=percent8.1 center ; define p2 /computed "%" format=percent8.1 center ; define p3 /computed "%" format=percent8.1 center ; define total/computed "Services" width=10 center; compute newcol /char length=15; IF _BREAK_='_RBREAK_' THEN newcol = 'Total'; else newcol = put(referral,myrows.); endcomp; compute p1; p1 = CHI.sum /n; endcomp; compute p2; p2 = HV.sum /n; endcomp; compute p3; p3 = TS.sum /n; endcomp; compute total; total = sum(CHI.sum, HV.sum, TS.sum); endcomp; rbreak after /summarize; where CHI ne. or HV ne. or TS ne. ; run; 11

proc report data=work.multir missing nowd; col referral newcol n CHI P1 total; define referral /group noprint; define n / ‘Children’ center; define newcol/computed ‘Referral’; define CHI / analysis ‘CHI’ sum; define P1 /computed ‘%’; compute newcol /char length=15; if _BREAK_=‘_RBREAK_’ then newcol= 'Total'; else newcol = put(referral,myrows.); endcomp; compute P1; P1 = CHI.sum /n; endcomp; define total/computed ‘Services’ width=10; compute total; total = sum(chi.sum); endcomp; rbreak after / summarize; where CHI ne.; run; Example Values Macro Variables Work&Lib Multir&d referral&row Referral&rowlabel Myrows&rowformat Children&obslabel Services&totallabel CHI HV TS&series CHI^HV^TS&labels Libref and Data Set Row variable, label and format Observation Label Total Label Variables for the multiple response item Labels for each variable 12

%macro chooseall(lib,d,row,rowlabel,rowformat,obslabel,totallabel,series,labels); proc report data=&lib..&d missing nowd; col &row newcol n [1 SERIES AND PERCENT] total; [e.g. CHI p1 HV p2 TS p3] define &row /group left width=15 noprint; define newcol /computed “ &rowlabel “; define n/format=8.0 “ &obslabel " center; [2 DEFINE EACH SERIES VARIABLE ] [e.g. define CHI / analysis sum "CHI";] [3 DEFINE PERCENT FOR EACH] [e.g. define p1 /computed "%“ ;] define total/computed “ &totallabel " width=10 center; compute newcol /char length=15; IF _BREAK_='_RBREAK_' THEN newcol = 'Total'; else newcol = put( &row,” &rowformat.. “); endcomp; [4 COMPUTE EACH PERCENT] [ e.g. compute p1; p1=CHI.sum /n; endcomp;] compute total; [5 COMPUTE TOTAL] [e.g. total = sum(CHI.sum, HV.sum, TS.sum);] endcomp; rbreak after /summarize; [6 CREATE A WHERE STATEMENT] [e.g. where CHI ne. or HV ne. or TS ne. ;] run; %mend; 13

14 %macro chooseall(lib,d,row,rowlabel,rowformat,obslabel,totallabel,series,labels); %let vargroup =; %*[1 COLUMN SERIES AND PERCENTS] ; %let define =; %*[2 DEFINE EACH SERIES VARIABLE]; %let definep =; %*[3 DEFINE PERCENT FOR EACH]; %let computedp =; %*[4 COMPUTE EACH PERCENT] ; %let total=; %* [5 COMPUTE TOTAL]; %let where=; %* [6 CREATE A WHERE STATEMENT]; %*Iterate through each variable in series; %let i = 1; %do %until(%scan(&series,&i)= | &i > 50); %let var = %scan(&series,&i); %let label = %scan(&labels,&i,%str(^)); %let i = %eval(&i + 1); %end; %*Remove the comma and or; %let total = %substr(&total,1,%eval(%length(&total) - 1)); %let where = %substr(&where,1,%eval(%length(&where) - 2)); %*[PROC REPORT FROM PREVIOUS SLIDE]; %mend; %*[1 COLUMN SERIES AND PERCENTS] ; %let vargroup = &vargroup &var p&i; %*[2 DEFINE EACH SERIES VARIABLE ]; %let define =&define define &var / analysis sum "&label" format=5.0 center%str(;); %*[3 DEFINE PERCENT FOR EACH]; %let definep = &definep define p&i /computed "%" format=percent8.1 center %str(;); %* [5 COMPUTE TOTAL]; %let total= &total &var..sum %str(,); %* [6 CREATE A WHERE STATEMENT]; %let where = &where &var ne %str(.) or;

 PROC REPORT can Generate Client-Quality Tabulations of Multiple Response Items (MRI)  A Relatively Concise Macro can be Used to Generate the Extended PROC REPORT Syntax  Limitations ◦ The MRI variables must be coded 1=Yes, 0=No ◦ Many MRI variables requires table breaks 15

Your comments and questions are valued and encouraged. Patrick Thornton Ph.D. Sr. Scientific Programmer/Analyst SRI International, Center for Education and Human Services Phone: Fax: Web: 16