An Introduction to Proc Transpose David P. Rosenfeld HR Consultant, Workforce Planning & Data Management City of Toronto.

Slides:



Advertisements
Similar presentations
Spreadsheet Software Data Objects  Cells and groups of cells  Containing text, numbers, formulas. Operations File menu – performed on whole files. Edit.
Advertisements

Axio Research E-Compare A Tool for Data Review Bill Coar.
Slide C.1 SAS MathematicalMarketing Appendix C: SAS Software Uses of SAS  CRM  datamining  data warehousing  linear programming  forecasting  econometrics.
The Knight’s Tour in Chess – Implementing a Heuristic Solution John R Gerlach The Knight’s Tour in Chess – Implementing a Heuristic Solution John R Gerlach.
Outline Proc Report Tricks Kelley Weston. Outline Examples 1.Text that spans columnsText that spans columns 2.Patient-level detail in the titlesPatient-level.
Knowing Understanding the Basics Writing your own code part 2 SAS Lab.
“Come out of the desert of ignorance to the OASUS of knowledge” Proc du Jour: PROC TRANSPOSE Tom Kari Tom Kari Consulting OASUS, November.
Assignmnet: Simple Random Sampling With Replacement Some Solutions.
Visualizing Multiple Physician Office Locations Exercise 9 GIS in Planning and Public Health Wansoo Im, Ph.D.
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.
Assignmnet: Simple Random Sampling With Replacement Some Solutions.
Spreadsheet Design Module S & Supplemental Resources on Class Website.
Basic And Advanced SAS Programming
Let SAS Do the Coding for You! Robert Williams Business Info Analyst Sr. WellPoint Inc.
SAS Programming SAS Data Mart. Outline Access different format of data for SAS SAS data mart SAS data manipulation 2.
Automating survey data validation using SAS macros Eric Bush, DVM, MS Centers for Epidemiology and Animal Health Fort Collins, CO.
Topics in Data Management SAS Data Step. Combining Data Sets I - SET Statement Data available on common variables from different sources. Multiple datasets.
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
Collection and Analysis of Data CPH 608 Spring 2015.
Biostatistics Analysis Center Center for Clinical Epidemiology and Biostatistics University of Pennsylvania School of Medicine Minimum Documentation Requirements.
Copyright © 2006, SAS Institute Inc. All rights reserved. Enterprise Guide 4.2 : A Primer SHRUG : Spring 2010 Presented by: Josée Ranger-Lacroix SAS Institute.
Qian Zhao, J&J Consumer Companies, Inc. Jun (John) Wang, J&J Consumer China Ltd Ruofei Hao, J&J Consumer Companies, Inc. PharmaSUG 2015 Paper #BB11.
SAS SQL SAS Seminar Series
Nasca Access BasicsMore Access Access Again Access Continued Access Leftovers.
SAS PROGRAMMING II COMBINING AND MANAGING SAS DATA SETS a. Multiple input data sets b. SAS special variables c. Collapsing techniques d. Reshaping SAS.
A Brief Introduction to PROC TRANSPOSE prepared by Voytek Grus for
Knowing Understanding the Basics Writing your own code SAS Lab.
Introduction to Using the Data Step Hash Object with Large Data Sets Richard Allen Peak Stat.
1 SAS 1-liners SAS Coding Efficiencies. 2 Overview Less is more Always aim for robust, reusable and efficient code Coding efficiency versus processing.
Grant Brown.  AIDS patients – compliance with treatment  Binary response – complied or no  Attempt to find factors associated with better compliance.
Using the new Version 8 Template Procedure for Complete Control of SAS Output Style and Format David Ghan Technical Training Specialist SAS, Canada.
1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University.
Introduction to Enterprise Guide Jennifer Schmidt Rhonda Ellis Cassandra Hall.
Formats to the Rescue Gary McQuown Data and Analytic Solutions Inc. Fairfax, VA.
SAS Basics. Windows Program Editor Write/edit all your statements here. Log Watch this for any errors in program as it runs. Output Will automatically.
Chapter 4 concerns various SAS procedures (PROCs). Every PROC operates on: –the most recently created dataset –all the observations –all the appropriate.
Analysis Introduction Data files, SPSS, and Survey Statistics.
YET ANOTHER TIPS, TRICKS, TRAPS, TECHNIQUES PRESENTATION: A Random Selection of What I Learned From 15+ Years of SAS Programming John Pirnat Kaiser Permanente.
TASS Meeting Setting GuessingRows when Importing Excel Files September 19th, 2008 Setting GuessingRows when importing Excel Files Dr. Arthur Tabachneck,
SAS Basics. Windows Program Editor Write/edit all your statement here.
Time Series Data Processes by Tai Yu April 15, 2013.
An Introduction Katherine Nicholas & Liqiong Fan.
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.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
Customize SAS Output Using ODS Joan Dong. The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure.
Dynamic Generation of Data Steps on basis of Unique By-Group Permutations David Rosenfeld City of Toronto.
Chapter 6: Modifying and Combining Data Sets  The SET statement is a powerful statement in the DATA step DATA newdatasetname; SET olddatasetname;.. run;
Real Time Remote Access Comparing SAS and SPSS David Price Quy Do April 2013.
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.
Longitudinal Data Techniques: Looking Across Observations Ronald Cody, Ed.D., Robert Wood Johnson Medical School.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 16 & 17 By Tasha Chapman, Oregon Health Authority.
Applied Business Forecasting and Regression Analysis
Chapter 6: Modifying and Combining Data Sets
Chapter 4: Sorting, Printing, Summarizing
SAS Essentials How SAS Thinks
PROC DOC III: Self-generating Codebooks Using SAS®
Creating the Example Data
C Graphing Functions.
Introduction to DATA Step Programming: SAS Basics II
Outline READ DATA DATA STEPS MERGE DATA PROC IMPORT
Combining Data Sets in the DATA step.
Use of PROC TABULATE Out File to Customize Tables
TransCAD Working with Matrices 2019/4/29.
Introduction to SAS Lecturer: Chu Bin Lin.
Hans Baumgartner Penn State University
A Better Way to Flip (Transpose) a SAS® Dataset
Changing a file from being long to being wide*
Presentation transcript:

An Introduction to Proc Transpose David P. Rosenfeld HR Consultant, Workforce Planning & Data Management City of Toronto

* Without proc transpose, you have the drudgery of doing this fifteen times, and knowing all possible values in advance, annoying even with a macro. *; data col2; set home_count; if home='Bendale Acres'; format Bendale_Acres 5.; Bendale_Acres = count; keep year Bendale_Acres; *... *; data outcome; merge col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12 col13 col14 col15; by year;

PROC TRANSPOSE ; BY variable-1 variable-n> ; COPY variable(s); ID variable; IDLABEL variable; VAR variable(s);

proc sort data=sasuser.TASS_demo; by year; proc freq data=sasuser.tass_demo; by year; tables home/noprint list out=home_count; /* additional tables possible. */ data home_count; set home_count; format count 5.; PROC EXPORT DATA= WORK.home_count OUTFILE= "C:\sas\code\tass\proc_freq_output.dbf" DBMS=DBF REPLACE; RUN; /* output of proc freq before transposition. */

* Now transpose the table with proc transpose. *; * By variables are not transposed. *; * The value of the id variable becomes the column name. Is converted to SAS-friendly variable name if necessary. *; * The var variable (could be more than one) is the dependent variable, and is mapped to the column. *; proc transpose data=home_count out=home_count_transposed ; by year ; id home; var count; run; data home_count_transposed (drop=_name_ _label_); /* the name and label of the variable that held the values now mapped to the columns. */ retain year Bendale_Acres Carefree_Lodge Castleview_Wychwood Cummer_Lodge Executive_Office Fudger_House Kipling_Acres Lakeshore_Lodge Seven_Oaks True_Davidson_Acres Wesburn_Manor Admin__and_Sup__Services Adult_Day_Centres Regional_Services Supportive_Housing; /* Only use retain statement if column sequence matters. */ set home_count_transposed; * Now output to spreadsheet with proc export. *; PROC EXPORT DATA= WORK.home_count_transposed OUTFILE= "c:\sas\code\tass\LTC_Departures.xls" DBMS=EXCEL REPLACE; SHEET="Home"; RUN;

110 proc freq data=sasuser.tass_demo; by year; 111 tables home/noprint list out=home_count; /* additional tables possible. */ 112 NOTE: There were 644 observations read from the data set SASUSER.TASS_DEMO. NOTE: The data set WORK.HOME_COUNT has 41 observations and 4 variables. NOTE: PROCEDURE FREQ used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 113 data home_count; 114 set home_count; 115 format count 5.; 116 NOTE: There were 41 observations read from the data set WORK.HOME_COUNT. NOTE: The data set WORK.HOME_COUNT has 41 observations and 4 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds

117 PROC EXPORT DATA= WORK.home_count 118 OUTFILE= "C:\sas\code\tass\proc_freq_output.dbf" 119 DBMS=DBF REPLACE; NOTE: "C:\sas\code\tass\proc_freq_output.dbf" was successfully created. NOTE: PROCEDURE EXPORT used (Total process time): real time 0.09 seconds cpu time 0.00 seconds 120 RUN; /* output of proc freq before transposition. */ * Now transpose the table with proc transpose. *; 123 * By variables are not transposed. *; 124 * The value of the id variable becomes the column name. Is converted to SAS-friendly variable name if necessary. *; 125 * The var variable (could be more than one) is the dependent variable, and is mapped to the column. *; proc transpose data=home_count out=home_count_transposed ; 128 by year ; 129 id home; 130 var count; 131 run; NOTE: There were 41 observations read from the data set WORK.HOME_COUNT. NOTE: The data set WORK.HOME_COUNT_TRANSPOSED has 3 observations and 18 variables. NOTE: PROCEDURE TRANSPOSE used (Total process time): real time 0.01 seconds cpu time 0.01 seconds

data home_count_transposed 134 (drop=_name_ _label_); /* the name and label of the variable that held the values now mapped to the columns. */ 135 retain year Bendale_Acres Carefree_Lodge Castleview_Wychwood Cummer_Lodge Executive_Office Fudger_House 136 Kipling_Acres Lakeshore_Lodge Seven_Oaks True_Davidson_Acres Wesburn_Manor Admin__and_Sup__Services Adult_Day_Centres 137 Regional_Services Supportive_Housing; /* Only use retain statement if column sequence matters. */ 138 set home_count_transposed; 139 * Now output to spreadsheet with proc export. *; NOTE: There were 3 observations read from the data set WORK.HOME_COUNT_TRANSPOSED. NOTE: The data set WORK.HOME_COUNT_TRANSPOSED has 3 observations and 16 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 140 PROC EXPORT DATA= WORK.home_count_transposed 141 OUTFILE= "c:\sas\code\tass\LTC_Departures.xls" 142 DBMS=EXCEL REPLACE; 143 SHEET="Home"; 144 RUN; NOTE: New file "c:\sas\code\tass\LTC_Departures.xls" will be created if the export process succeeds. NOTE: "Home" was successfully created. NOTE: PROCEDURE EXPORT used (Total process time): real time 0.46 seconds cpu time 0.09 seconds

Thanks!