Www.OASUS.ca “Come out of the desert of ignorance to the OASUS of knowledge” Proc du Jour: PROC TRANSPOSE Tom Kari Tom Kari Consulting OASUS, November.

Slides:



Advertisements
Similar presentations
Haas MFE SAS Workshop Lecture 3:
Advertisements

The INFILE Statement Reading files into SAS from an outside source: A Very Useful Tool!
SAS Programming:File Merging and Manipulation. Reading External Files (review) data barf; * create the dataset BARF; infile ’s:\mysas\Table7.1'; * open.
A guide to the unknown…  A dataset is longitudinal if it tracks the same type of information on the same subjects at multiple points in time or space.
Knowing Understanding the Basics Writing your own code part 2 SAS Lab.
Creating a Compact Columnar Output with PROC REPORT Walter R. Young Principal Clinical Programmer Analyst Wyeth.
SAS Programming: Working With Variables. Data Step Manipulations New variables should be created during a Data step Existing variables should be manipulated.
Today: Run SAS programs on Saturn (UNIX tutorial) Runs SAS programs on the PC.
Beginning Data Manipulation HRP Topic 4 Oct 19 th 2011.
1 Creating and Tweaking Data HRP223 – 2010 October 24, 2011 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Basic And Advanced SAS Programming
1 Computer Applications in Epidemiology Dongmei Li Lecture 26 5/6/2009.
Generating Random Samples SAS, EXCEL, JMP, SPSS. Population of Data  Sample Data should be in a dataset where each row represents an individual unit,
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
Copyright © 2010, Meta-Xceed, Inc. All rights reserved. BI Flash and all other Meta-Xceed Inc. product or service names are registered trademarks or trademarks.
Coding for Excel Analysis Optional Exercise Map Your Hazards! Module, Unit 2 Map Your Hazards! Combining Natural Hazards with Societal Issues.
SAS SQL SAS Seminar Series
SAS PROC REPORT PROC TABULATE
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Chapter 9 Producing Descriptive Statistics PROC MEANS; Summarize descriptive statistics for continuous numeric variables. PROC FREQ; Summarize frequency.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
1 Experimental Statistics - week 4 Chapter 8: 1-factor ANOVA models Using SAS.
HPR Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.
1 Experimental Statistics - week 2 Review: 2-sample t-tests paired t-tests Thursday: Meet in 15 Clements!! Bring Cody and Smith book.
A Brief Introduction to PROC TRANSPOSE prepared by Voytek Grus for
Knowing Understanding the Basics Writing your own code SAS Lab.
EPIB 698C Lecture 2 Notes Instructor: Raul Cruz 2/14/11 1.
I OWA S TATE U NIVERSITY Department of Animal Science Getting Your Data Into SAS (Chapter 2 in the Little SAS Book) Animal Science 500 Lecture No. 3 September.
Chapter 17 Creating a Database.
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
Introduction to Enterprise Guide Jennifer Schmidt Rhonda Ellis Cassandra Hall.
Chapter 16: Using Lookup Tables to Match Data 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
A Simple Guide to Using SPSS ( Statistical Package for the Social Sciences) for Windows.
1 EPIB 698E Lecture 1 Notes Instructor: Raul Cruz 7/9/13.
SAS ODS (Output Delivery System) Donald Miller 812 Oswald Tower ;
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
YET ANOTHER TIPS, TRICKS, TRAPS, TECHNIQUES PRESENTATION: A Random Selection of What I Learned From 15+ Years of SAS Programming John Pirnat Kaiser Permanente.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Integrate, check and share documents Module 3.3. Integrate, check and share documents Module 3.3.
Common Sense Validation Using SAS Lisa Eckler Lisa Eckler Consulting Inc. TASS Interfaces, December 2015.
1 Statistical Software Programming. STAT 6360 –Statistical Software Programming Modifying and Combining Datasets For most tasks we need to work with multiple.
“Come out of the desert of ignorance to the OASUS of knowledge” Benchmarking and SAS Tom Kari, Tom Kari Consulting Ltd.
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.
An Introduction to Proc Transpose David P. Rosenfeld HR Consultant, Workforce Planning & Data Management City of Toronto.
“LAG with a WHERE” and other DATA Step Stories Neil Howard A.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
Chapter 17 Supplement: Alternatives to IF-THEN/ELSE Processing STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South.
Lesson 2 Topic - Reading in data Programs 1 and 2 in course notes –Chapter 2 (Little SAS Book)
1 Data Manipulation (with SQL) HRP223 – 2009 October 12, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Chapter 6: Modifying and Combining Data Sets  The SET statement is a powerful statement in the DATA step DATA newdatasetname; SET olddatasetname;.. run;
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
SAS Programming Training Instructor:Greg Grandits TA: Textbooks:The Little SAS Book, 5th Edition Applied Statistics and the SAS Programming Language, 5.
Four way analysis Nursing home residence Gender Age Death.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
Online Programming| Online Training| Real Time Projects | Certifications |Online Classes| Corporate Training |Jobs| CONTACT US: STANSYS SOFTWARE SOLUTIONS.
1 Ready To Become Really Productive Using PROC SQL? Sunil Gupta Gupta Programming.
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 5 & 6 By Ravi Mandal.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
Chapter 6: Modifying and Combining Data Sets
Chapter 2: Getting Data into SAS
Producing Descriptive Statistics
TransCAD Working with Matrices 2019/4/29.
Data Manipulation (with SQL)
Presentation transcript:

“Come out of the desert of ignorance to the OASUS of knowledge” Proc du Jour: PROC TRANSPOSE Tom Kari Tom Kari Consulting OASUS, November 20

Simplest case data SimpleTransposeIn; input A B C; cards; run; proc transpose data=SimpleTransposeIn out=SimpleTransposeOut; run; November 20, 2014Tom Kari, Tom Kari Consulting2

ID Variable data FinanceData; length Region $9; input Region NetSales; cards; EMNA 3253 EME 749 EMIO 430 EMSA 403 Corporate 4.8 run; proc transpose data=FinanceData out=Transposed; ID Region; run; November 20, 2014Tom Kari, Tom Kari Consulting3 Specifies one or more variables in the input data set whose formatted values name the transposed variables in the output data set. Can use with prefix, suffix, delimiter options. IDLabel statement provides a variable that contains the labels for the new variables.

BY Variable data QuarterlyData; length Region $9; input Region Quarter NetSales; cards; EMNA EME Corporate run; proc sort data=QuarterlyData; by Region; proc transpose data=QuarterlyData out=TransposedQuarterly prefix=Q; by Region; ID Quarter; var NetSales; run; November 20, 2014Tom Kari, Tom Kari Consulting4 Excludes one or more variables from being transposed Data must be sorted by the BY variable(s)

BY Variable (cont’d) November 20, 2014Tom Kari, Tom Kari Consulting5

Additional comments November 20, 2014Tom Kari, Tom Kari Consulting6 Like PROC SORT, this procedure is intended purely for data processing PROC TRANSPOSE has no provisions for ODS PROC TRANSPOSE will frequently convert numeric variables to character Enterprise Guide provides a good Transpose task

Use case 1: “Datapoint” files November 20, 2014Tom Kari, Tom Kari Consulting7 PersonNameGenderAgeHeight 1AlfredM1469 2AliceF BarbaraF CarolF HenryM JamesM JaneF JanetF JeffreyM JohnM JoyceF JudyF LouiseF MaryF PhilipM RobertM RonaldM ThomasM WilliamM PersonVariableValue 1NameAlfred 1GenderM 1Age14 1Height69 2NameAlice 2GenderF 2Age13 2Height56.5 3NameBarbara 3GenderF 3Age13 3Height65.3 … 76 rows

Convert from relational to “Datapoint” files November 20, 2014Tom Kari, Tom Kari Consulting8

Convert from “Datapoint” to relational November 20, 2014Tom Kari, Tom Kari Consulting9

Use case 2: Edit Spreadsheets November 20, 2014Tom Kari, Tom Kari Consulting10 Spreadsheets are a terrible way to transfer important data from one organization to another: They are prone to ad-hoc changes; There’s always the risk of transferring the wrong month, version, location; “Glitches” frequently pop up. Yet everybody does it!

What could go wrong? November 20, 2014Tom Kari, Tom Kari Consulting11

What could go wrong? November 20, 2014Tom Kari, Tom Kari Consulting12

What could go wrong? November 20, 2014Tom Kari, Tom Kari Consulting13

What could go wrong? November 20, 2014Tom Kari, Tom Kari Consulting14

Spaghetti code! November 20, 2014Tom Kari, Tom Kari Consulting15

A different approach November 20, 2014Tom Kari, Tom Kari Consulting16 Transpose one of your spreadsheets (turn rows and columns into rows identified by cell id, e.g. B17) Separate your cells into “static” (the contents should always be the same), and “fixed” (contains data that we want to capture). Set this table up as a reference table. For your production processing: –Pull your spreadsheet into SAS (PROC IMPORT); –Transpose the cells same way, into rows with a cell id; –Match to the reference table by cell id: If static and values don’t match, we have a problem. If a reference cell is empty, and a test cell isn’t, or vice versa, do we have a problem? –Pull out your “fixed” cell ids (we know what they are from the reference table), and transpose them. You’ll get one record with your data!

November 20, 2014Tom Kari, Tom Kari Consulting17