EXAMPLE 3: MATCHING DATA FROM RESPONDENTS AT 2 OR MORE WAVES (LONG FORMAT)

Size: px
Start display at page:

Download "EXAMPLE 3: MATCHING DATA FROM RESPONDENTS AT 2 OR MORE WAVES (LONG FORMAT)"

Transcription

1 EXAMPLE 3: MATCHING DATA FROM RESPONDENTS AT 2 OR MORE WAVES (LONG FORMAT) DESCRIPTION: This example shows how to combine the data on respondents from the first two waves of Understanding Society into a long format. This Example also shows how to compute transitions (change in marital status and in personal income from wave 1 to wave 2) in the case of long format. The results obtained in this example (long format) should be the same as the ones in Example 2 (wide format). FILES: a_indresp and b_indresp WAVES: 1 and 2 STEPS: 1. Merge waves 1 and 2 into long format 2. Inspect the data, deal with missing values 3. Identify transitions (e.g. change in marital status and change in pay) 4. Conversion from wide to long format and from long to wide format NEW COMMANDS: - Combining waves and data manipulation: proc append, proc rename, proc sort, data set - Repeating the same series of commands using a macro 1 E x a m p l e 3

2 3.1 COMBINING WAVE 1 AND WAVE 2 DATA INTO LONG FORMAT In this section we will discuss how to combine data from wave 1 and wave 2 into a data file in long format. To do that we need to first make some changes to the dataset of each wave: create a variable to identify which wave the data belongs to: 1 for wave 1, 2 for wave 2,... drop the wave prefix from all variables so that SAS can recognize the variables from two waves as the same variable. Before we get started set all the relevant directories: /*Exercise 3*/ proc datasets lib=work kill nolist memtype=data; quit; /*for sharing with others you will want to write to a log file - but for this exercise we have commented it out*/ /* writing all output to a log file */ /*filename myoutput "SET OUTPUT FILE HERE.txt"; proc printto print=myoutput new; */ /* writing to a log file */ /*filename mylog "SET LOG FILE HERE.log"; proc printto log=mylog new; */ /* defining a library where files can be permanently stored */ libname dir 'define area where files will be permanently stored; options nofmterr; Let us start with wave 1 Read data file a_indresp into SAS Rename all the variables by dropping the prefix a_. This is necessary so that each variable has the same name across waves and can be appended into a single variable. Create a variable that identifies which wave the observation comes from. /* reading in wave 1 data from SPSS file into SAS */ proc import datafile = "specify where your data file is" out=a_indresp dbms= sav replace; /* drop the wave prefixes */ data wave1 (rename=(a_hidp=hidp a_istrtdaty=istrtdaty a_sex=sex a_mastat_dv=mastat_dv a_julkjb=julkjb a_paygu_dv=paygu_dv a_sclfsato=sclfsato a_jbstat=jbstat)); 2 E x a m p l e 3

3 set a_indresp; waveno=1; keep waveno a_hidp pidp a_istrtdaty a_sex a_mastat_dv a_julkjb a_paygu_dv a_sclfsato a_jbstat; The data step option rename renames the variables by specifying first the original name and then the name we want it to be changed to. So, a_hidp will be renamed to hidp, a_sex to sex and so on. Original variable name a_hidp pidp a_sex a_paygu_dv New variable name hidp pidp sex paygu_dv We could deal with missing values here, as we did in the wide format in Example 2, but it is more efficient to do it after the two data files have been combined. Now perform the same steps for wave 2: /* reading in wave 2 data from SPSS file into SAS */ proc import datafile="specify where your data file is" out=b_indresp dbms= sav replace; data wave2 (rename=(b_hidp=hidp b_istrtdaty=istrtdaty b_sex=sex b_mastat_dv=mastat_dv b_julkjb=julkjb b_paygu_dv=paygu_dv b_sclfsato=sclfsato b_jbstat=jbstat)); set b_indresp; waveno=2; keep waveno b_hidp pidp b_istrtdaty b_sex b_mastat_dv b_julkjb b_paygu_dv b_sclfsato b_jbstat; There are multiple ways to combine the files into long format. Here we use a data step, but another method is explored below in 3.4. /* appends dataset wave2 to dataset wave1 and creates a new longitudinal dataset in long format*/ set wave1 wave2; This appends dataset wave2 to wave1 and then creates a new longitudinal dataset in long format called wave12long in the work directory. 3 E x a m p l e 3

4 Note: Although care is taken to retain the same categories of variables across waves, sometimes these need to be changed when new categories become relevant. So, always check the documentation to see if that has happened: This can also be checked by using proc format, for example: proc format library=work fmtlib; select a_istr2a b_istrta; Now look at the combined data file. /* examine the new long format file */ proc univariate data=wave12long; title ''; /*resetting the title option from previous exercise */ var sex mastat_dv; proc freq data=wave12long; tables waveno; 3.2 LOOKING AT TRANSITIONS DATA PREPARATION As in Example 2 recode negative values to. so that SAS can recognize these as missing. /*Looking at transitions*/ /* recode negative values to system missings */ /*this is a simpler method to accomplish the same thing at the array - but it doesn't scale as easily*/ /*if istrtdaty<0 then istrtdaty=.; if sex<0 then sex=.; if mastat_dv<0 then mastat_dv=.; if julkjb<0 then julkjb=.; if paygu_dv<0 then paygu_dv=.; if sclfsato<0 then sclfsato=.;*/ *Changing all out of range coding values to missing; *The _numeric_ option means this command creates an array of all numerical variables; array aa (*) _numeric_; do i=1 to dim(aa); if aa(i) < 0 then aa(i) =.; drop i; end; 4 E x a m p l e 3

5 As we are interested in transitions across the two waves, we will be creating variables that identify these transitions. First however, we need to know which observations are in both waves so that we can construct a balanced panel. Using proc sort, we put the data in order, sorting first by pidp and then by waveno. proc sort data=wave12long; by pidp waveno; To have a balanced panel we keep only those present in both waves. This command uses a proc sql command (SAS also understands SQL). The command tells SAS to count the number of observations by pidp and create a table called t1. This is in the work directory. proc sql; create table wave12long as select *, count(pidp) as counter from wave12long group by pidp order by pidp, waveno; Then we run a data command to only keep respondents who are in both waves of data. if counter=1 then delete; 3.3 IDENTIFYING TRANSITIONS CHANGE IN MARITAL STATUS AND PAY We will now create the same variable as in Example 2 to identify and summarise changes in marital status. But as the data is now in LONG format rather than WIDE format we will need different commands. As in Example 2, first recode marital status into smaller number of categories, generating a new variable, marital. if mastat_dv=1 then marital=1; if mastat_dv in (2,3,10) then marital=2; if mastat_dv in (4,5,7,8) then marital=3; if mastat_dv in (6,9) then marital=4; If the format marital is already defined from Exercise 2, it can be applied to the dataset without recreating it. format marital marital.; 5 E x a m p l e 3

6 To create a variable marchg that measures marital status transitions, we will make use of the array and lag function. The array command defines a list of variables which SAS run a set of commands on and loop over each variable in the array. The dataset needs to be sorted by pidp and wave but we have already done this. /* Creating measures of change */ by pidp waveno; lagmar=lag1(marital); marchg=(lagmar*10)+marital; diffwage=dif(paygu_dv); if first.pidp then do; diffwage=.; end; label marchg = "change in marital status between waves 1 and 2"; label diffwage = "difference in wages between waves 2 and 1"; proc format; value marchg 11= "remains single" 12= "was single now partnered" 13= "was single now separated" 14= "was single now widowed" 21= "was partnered now single" 22= "remains in partnership" 23= "was partnered now separated" 24= "was partnered now widowed" 31= "was separated now single" 32= "was separated now partnered" 33= "still separated" 34= "was separated now widowed" 41= "was widowed now single" 42= "was widowed now partnered" 43= "was widowed now separated" 44= "still widowed"; format marchg marchg.; Task: Label the variable and its values (see Example 2) and look at the frequency distribution of change in marital status. Compare with the frequency of this variable in Example 2. Task: Create a variable diffwage which measures the change in pay (paygu_dv) between the two waves. 6 E x a m p l e 3

7 Question: How does pay change vary by sex and by marital status and sex? It is a good idea to only keep the second observation for each person when you are finished creating change variables, to make it easier to interpret tabulations and other results. We can do this using a data step with an if statement. proc sort data=wave12long; by pidp waveno; if waveno=1 then delete; 3.4 COMBINING DATASETS INTO LONG FORMAT WHEN THERE ARE MORE THAN TWO WAVES When you are planning to merge data from more than two waves it is generally a good idea to write the commands into a loop. This reduces the amount of code you have to write, but more importantly it reduces the chance of error. For this exercise we will demonstrate how to append 4 waves of Understanding Society together. The basic operations are the same as in the first part of this exercise. For each wave: Open the file; Generate a variable (wave) to identify the wave of this data; Rename the variables by dropping the wave prefix; Save as a temporary file, one for each wave: To begin with we need to import the extra files into SAS. proc import datafile = "SPECIFY DIRECTORY WHERE DATA IS HELD" out=a_indresp dbms= sav replace; proc import datafile = "SPECIFY DIRECTORY WHERE DATA IS HELD" out=b_indresp dbms= sav replace; proc import datafile = "SPECIFY DIRECTORY WHERE DATA IS HELD" out=c_indresp dbms= sav replace; proc import datafile = "SPECIFY DIRECTORY WHERE DATA IS HELD" out=d_indresp dbms= sav replace; Now all the datasets are in SAS, we can use a macro to combine them. This is like a SAS program where some part of the program changes as it is completed. In our case, this macro uses the set function in a data step to add a dataset called wave1, to a file called wave2, and increases the number on the end of the dataset name by 1 each time until it gets to 4. The code between %macro and %mend defines the macro called combine, and %combine tells SAS to execute the program. 7 E x a m p l e 3

8 %macro combine(w=,y=); data wave&y.; set work.&w._indresp(rename=(&w._hidp=hidp &w._istrtdaty=istrtdaty &w._sex=sex)); waveno=&y.; keep hidp pidp istrtdaty sex waveno; proc freq data=wave&y.; tables sex; title "wave &y."; proc append BASE=wave1234long DATA=wave&y. force; quit; %mend; %combine(w=a,y=1); title; %combine(w=b,y=2); title; %combine(w=c,y=3); title; %combine(w=d,y=4); title; And then check that all four waves have been included using proc freq. proc freq data=wave1234long; tables waveno; That s that. Now that you have merged all data you would carry on creating your transition variables for all waves. You can now save your final dataset data dir.wave12long; One final task, clear all the datasets you ve created: /* Clean SAS work directory */ proc datasets lib=work nolist kill memtype=all; /*relevant only if you are printing to external log files - stop writing to external log and output files and simply write to the SAS windows proc printto; quit; */ 8 E x a m p l e 3

EXAMPLE 3: MATCHING DATA FROM RESPONDENTS AT 2 OR MORE WAVES (LONG FORMAT)

EXAMPLE 3: MATCHING DATA FROM RESPONDENTS AT 2 OR MORE WAVES (LONG FORMAT) EXAMPLE 3: MATCHING DATA FROM RESPONDENTS AT 2 OR MORE WAVES (LONG FORMAT) DESCRIPTION: This example shows how to combine the data on respondents from the first two waves of Understanding Society into

More information

EXAMPLE 2: INTRODUCTION TO SAS AND SOME NOTES ON HOUSEKEEPING PART II - MATCHING DATA FROM RESPONDENTS AT 2 WAVES INTO WIDE FORMAT

EXAMPLE 2: INTRODUCTION TO SAS AND SOME NOTES ON HOUSEKEEPING PART II - MATCHING DATA FROM RESPONDENTS AT 2 WAVES INTO WIDE FORMAT EXAMPLE 2: PART I - INTRODUCTION TO SAS AND SOME NOTES ON HOUSEKEEPING PART II - MATCHING DATA FROM RESPONDENTS AT 2 WAVES INTO WIDE FORMAT USING THESE WORKSHEETS For each of the worksheets you have a

More information

Use data on individual respondents from the first 17 waves of the British Household

Use data on individual respondents from the first 17 waves of the British Household Applications of Data Analysis (EC969) Simonetta Longhi and Alita Nandi (ISER) Contact: slonghi and anandi; @essex.ac.uk Week 1 Lecture 2: Data Management Use data on individual respondents from the first

More information

Contents of SAS Programming Techniques

Contents of SAS Programming Techniques Contents of SAS Programming Techniques Chapter 1 About SAS 1.1 Introduction 1.1.1 SAS modules 1.1.2 SAS module classification 1.1.3 SAS features 1.1.4 Three levels of SAS techniques 1.1.5 Chapter goal

More information

3. Almost always use system options options compress =yes nocenter; /* mostly use */ options ps=9999 ls=200;

3. Almost always use system options options compress =yes nocenter; /* mostly use */ options ps=9999 ls=200; Randy s SAS hints, updated Feb 6, 2014 1. Always begin your programs with internal documentation. * ***************** * Program =test1, Randy Ellis, first version: March 8, 2013 ***************; 2. Don

More information

using and Understanding Formats

using and Understanding Formats using and Understanding SAS@ Formats Howard Levine, DynaMark, Inc. Oblectives The purpose of this paper is to enable you to use SAS formats to perform the following tasks more effectively: Improving the

More information

2. Don t forget semicolons and RUN statements The two most common programming errors.

2. Don t forget semicolons and RUN statements The two most common programming errors. Randy s SAS hints March 7, 2013 1. Always begin your programs with internal documentation. * ***************** * Program =test1, Randy Ellis, March 8, 2013 ***************; 2. Don t forget semicolons and

More information

A Cross-national Comparison Using Stacked Data

A Cross-national Comparison Using Stacked Data A Cross-national Comparison Using Stacked Data Goal In this exercise, we combine household- and person-level files across countries to run a regression estimating the usual hours of the working-aged civilian

More information

A SAS Macro for Producing Benchmarks for Interpreting School Effect Sizes

A SAS Macro for Producing Benchmarks for Interpreting School Effect Sizes A SAS Macro for Producing Benchmarks for Interpreting School Effect Sizes Brian E. Lawton Curriculum Research & Development Group University of Hawaii at Manoa Honolulu, HI December 2012 Copyright 2012

More information

Electricity Forecasting Full Circle

Electricity Forecasting Full Circle Electricity Forecasting Full Circle o Database Creation o Libname Functionality with Excel o VBA Interfacing Allows analysts to develop procedural prototypes By: Kyle Carmichael Disclaimer The entire presentation

More information

Presentation Goals. Now that You Have Version 8, What Do You Do? Top 8 List: Reason #8 Generation Data Sets. Top 8 List

Presentation Goals. Now that You Have Version 8, What Do You Do? Top 8 List: Reason #8 Generation Data Sets. Top 8 List Presentation Goals Now that You Have Version 8, What Do You Do? Michael L. Davis Bassett Consulting Services, Inc. September 13, 2000 highlight incentives to switch consider migration strategies identify

More information

Techniques for Writing Robust SAS Macros. Martin Gregory. PhUSE Annual Conference, Oct 2009, Basel

Techniques for Writing Robust SAS Macros. Martin Gregory. PhUSE Annual Conference, Oct 2009, Basel Techniques for Writing Robust SAS Macros Martin Gregory PhUSE Annual Conference, 19-21 Oct 2009, Basel Overview Why robustness? Summary of techniques Types of macros considered An example from real life:

More information

SAS - By Group Processing umanitoba.ca/centres/mchp

SAS - By Group Processing umanitoba.ca/centres/mchp SAS - By Group Processing umanitoba.ca/centres/mchp Winnipeg SAS users Group SAS By Group Processing Are you First or Last In Line Charles Burchill Manitoba Centre for Health Policy, University of Manitoba

More information

Table of Contents. The RETAIN Statement. The LAG and DIF Functions. FIRST. and LAST. Temporary Variables. List of Programs.

Table of Contents. The RETAIN Statement. The LAG and DIF Functions. FIRST. and LAST. Temporary Variables. List of Programs. Table of Contents List of Programs Preface Acknowledgments ix xvii xix The RETAIN Statement Introduction 1 Demonstrating a DATA Step with and without a RETAIN Statement 1 Generating Sequential SUBJECT

More information

EXAMPLE 10: PART I OFFICIAL GEOGRAPHICAL IDENTIFIERS IN THE UNDERSTANDING SOCIETY PART II LINKING MACRO-LEVEL DATA AT THE LSOA LEVEL

EXAMPLE 10: PART I OFFICIAL GEOGRAPHICAL IDENTIFIERS IN THE UNDERSTANDING SOCIETY PART II LINKING MACRO-LEVEL DATA AT THE LSOA LEVEL EXAMPLE 10: PART I OFFICIAL GEOGRAPHICAL IDENTIFIERS IN THE UNDERSTANDING SOCIETY PART II LINKING MACRO-LEVEL DATA AT THE LSOA LEVEL DESCRIPTION: The objective of this example is to illustrate how external

More information

A SAS Macro Utility to Modify and Validate RTF Outputs for Regional Analyses Jagan Mohan Achi, PPD, Austin, TX Joshua N. Winters, PPD, Rochester, NY

A SAS Macro Utility to Modify and Validate RTF Outputs for Regional Analyses Jagan Mohan Achi, PPD, Austin, TX Joshua N. Winters, PPD, Rochester, NY PharmaSUG 2014 - Paper BB14 A SAS Macro Utility to Modify and Validate RTF Outputs for Regional Analyses Jagan Mohan Achi, PPD, Austin, TX Joshua N. Winters, PPD, Rochester, NY ABSTRACT Clinical Study

More information

Using an ICPSR set-up file to create a SAS dataset

Using an ICPSR set-up file to create a SAS dataset Using an ICPSR set-up file to create a SAS dataset Name library and raw data files. From the Start menu, launch SAS, and in the Editor program, write the codes to create and name a folder in the SAS permanent

More information

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS TO SAS NEED FOR SAS WHO USES SAS WHAT IS SAS? OVERVIEW OF BASE SAS SOFTWARE DATA MANAGEMENT FACILITY STRUCTURE OF SAS DATASET SAS PROGRAM PROGRAMMING LANGUAGE ELEMENTS OF THE SAS LANGUAGE RULES FOR SAS

More information

PHPM 672/677 Lab #2: Variables & Conditionals Due date: Submit by 11:59pm Monday 2/5 with Assignment 2

PHPM 672/677 Lab #2: Variables & Conditionals Due date: Submit by 11:59pm Monday 2/5 with Assignment 2 PHPM 672/677 Lab #2: Variables & Conditionals Due date: Submit by 11:59pm Monday 2/5 with Assignment 2 Overview Most assignments will have a companion lab to help you learn the task and should cover similar

More information

Tales from the Help Desk 6: Solutions to Common SAS Tasks

Tales from the Help Desk 6: Solutions to Common SAS Tasks SESUG 2015 ABSTRACT Paper BB-72 Tales from the Help Desk 6: Solutions to Common SAS Tasks Bruce Gilsen, Federal Reserve Board, Washington, DC In 30 years as a SAS consultant at the Federal Reserve Board,

More information

General Tips for Working with Large SAS datasets and Oracle tables

General Tips for Working with Large SAS datasets and Oracle tables General Tips for Working with Large SAS datasets and Oracle tables 1) Avoid duplicating Oracle tables as SAS datasets only keep the rows and columns needed for your analysis. Use keep/drop/where directly

More information

Choosing the Right Procedure

Choosing the Right Procedure 3 CHAPTER 1 Choosing the Right Procedure Functional Categories of Base SAS Procedures 3 Report Writing 3 Statistics 3 Utilities 4 Report-Writing Procedures 4 Statistical Procedures 6 Available Statistical

More information

SAS Training Spring 2006

SAS Training Spring 2006 SAS Training Spring 2006 Coxe/Maner/Aiken Introduction to SAS: This is what SAS looks like when you first open it: There is a Log window on top; this will let you know what SAS is doing and if SAS encountered

More information

Stata SHP Data Management (Stata 12)

Stata SHP Data Management (Stata 12) Stata SHP Data Management (Stata 12) Ursina Kuhn and Oliver Lipps, FORS, Lausanne Version August 2013 Content Aim of this documentation... 2 1 Missing values in the SHP... 2 2 Merge files... 3 2.1 Illustration

More information

A Simple Framework for Sequentially Processing Hierarchical Data Sets for Large Surveys

A Simple Framework for Sequentially Processing Hierarchical Data Sets for Large Surveys A Simple Framework for Sequentially Processing Hierarchical Data Sets for Large Surveys Richard L. Downs, Jr. and Pura A. Peréz U.S. Bureau of the Census, Washington, D.C. ABSTRACT This paper explains

More information

Base and Advance SAS

Base and Advance SAS Base and Advance SAS BASE SAS INTRODUCTION An Overview of the SAS System SAS Tasks Output produced by the SAS System SAS Tools (SAS Program - Data step and Proc step) A sample SAS program Exploring SAS

More information

A Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN

A Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN Paper 045-29 A Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN ABSTRACT: PROC MEANS analyzes datasets according to the variables listed in its Class

More information

Paper CC16. William E Benjamin Jr, Owl Computer Consultancy LLC, Phoenix, AZ

Paper CC16. William E Benjamin Jr, Owl Computer Consultancy LLC, Phoenix, AZ Paper CC16 Smoke and Mirrors!!! Come See How the _INFILE_ Automatic Variable and SHAREBUFFERS Infile Option Can Speed Up Your Flat File Text-Processing Throughput Speed William E Benjamin Jr, Owl Computer

More information

SQL, HASH Tables, FORMAT and KEY= More Than One Way to Merge Two Datasets

SQL, HASH Tables, FORMAT and KEY= More Than One Way to Merge Two Datasets TF19 SQL, HASH Tables, FORMAT and KEY= More Than One Way to Merge Two Datasets David Franklin TheProgrammers Cabin.com Introduction Merging data is one of the most common data manipulation task done with

More information

Matt Downs and Heidi Christ-Schmidt Statistics Collaborative, Inc., Washington, D.C.

Matt Downs and Heidi Christ-Schmidt Statistics Collaborative, Inc., Washington, D.C. Paper 82-25 Dynamic data set selection and project management using SAS 6.12 and the Windows NT 4.0 file system Matt Downs and Heidi Christ-Schmidt Statistics Collaborative, Inc., Washington, D.C. ABSTRACT

More information

GETTING DATA INTO THE PROGRAM

GETTING DATA INTO THE PROGRAM GETTING DATA INTO THE PROGRAM 1. Have a Stata dta dataset. Go to File then Open. OR Type use pathname in the command line. 2. Using a SAS or SPSS dataset. Use Stat Transfer. (Note: do not become dependent

More information

Using a Control Dataset to Manage Production Compiled Macro Library Curtis E. Reid, Bureau of Labor Statistics, Washington, DC

Using a Control Dataset to Manage Production Compiled Macro Library Curtis E. Reid, Bureau of Labor Statistics, Washington, DC AP06 Using a Control Dataset to Manage Production Compiled Macro Library Curtis E. Reid, Bureau of Labor Statistics, Washington, DC ABSTRACT By default, SAS compiles and stores all macros into the WORK

More information

Data-Analysis Exercise Fitting and Extending the Discrete-Time Survival Analysis Model (ALDA, Chapters 11 & 12, pp )

Data-Analysis Exercise Fitting and Extending the Discrete-Time Survival Analysis Model (ALDA, Chapters 11 & 12, pp ) Applied Longitudinal Data Analysis Page 1 Data-Analysis Exercise Fitting and Extending the Discrete-Time Survival Analysis Model (ALDA, Chapters 11 & 12, pp. 357-467) Purpose of the Exercise This data-analytic

More information

IPUMS Training and Development: Requesting Data

IPUMS Training and Development: Requesting Data IPUMS Training and Development: Requesting Data IPUMS PMA Exercise 2 OBJECTIVE: Gain an understanding of how IPUMS PMA service delivery point datasets are structured and how it can be leveraged to explore

More information

Create a Format from a SAS Data Set Ruth Marisol Rivera, i3 Statprobe, Mexico City, Mexico

Create a Format from a SAS Data Set Ruth Marisol Rivera, i3 Statprobe, Mexico City, Mexico PharmaSUG 2011 - Paper TT02 Create a Format from a SAS Data Set Ruth Marisol Rivera, i3 Statprobe, Mexico City, Mexico ABSTRACT Many times we have to apply formats and it could be hard to create them specially

More information

Introduction to SAS. Cristina Murray-Krezan Research Assistant Professor of Internal Medicine Biostatistician, CTSC

Introduction to SAS. Cristina Murray-Krezan Research Assistant Professor of Internal Medicine Biostatistician, CTSC Introduction to SAS Cristina Murray-Krezan Research Assistant Professor of Internal Medicine Biostatistician, CTSC cmurray-krezan@salud.unm.edu 20 August 2018 What is SAS? Statistical Analysis System,

More information

A Guided Tour Through the SAS Windowing Environment Casey Cantrell, Clarion Consulting, Los Angeles, CA

A Guided Tour Through the SAS Windowing Environment Casey Cantrell, Clarion Consulting, Los Angeles, CA A Guided Tour Through the SAS Windowing Environment Casey Cantrell, Clarion Consulting, Los Angeles, CA ABSTRACT The SAS system running in the Microsoft Windows environment contains a multitude of tools

More information

AURA ACADEMY SAS TRAINING. Opposite Hanuman Temple, Srinivasa Nagar East, Ameerpet,Hyderabad Page 1

AURA ACADEMY SAS TRAINING. Opposite Hanuman Temple, Srinivasa Nagar East, Ameerpet,Hyderabad Page 1 SAS TRAINING SAS/BASE BASIC THEORY & RULES ETC SAS WINDOWING ENVIRONMENT CREATION OF LIBRARIES SAS PROGRAMMING (BRIEFLY) - DATASTEP - PROC STEP WAYS TO READ DATA INTO SAS BACK END PROCESS OF DATASTEP INSTALLATION

More information

Efficiently Join a SAS Data Set with External Database Tables

Efficiently Join a SAS Data Set with External Database Tables ABSTRACT Paper 2466-2018 Efficiently Join a SAS Data Set with External Database Tables Dadong Li, Michael Cantor, New York University Medical Center Joining a SAS data set with an external database is

More information

Reading in Data Directly from Microsoft Word Questionnaire Forms

Reading in Data Directly from Microsoft Word Questionnaire Forms Paper 1401-2014 Reading in Data Directly from Microsoft Word Questionnaire Forms Sijian Zhang, VA Pittsburgh Healthcare System ABSTRACT If someone comes to you with hundreds of questionnaire forms in Microsoft

More information

Exporting & Importing Datasets & Catalogs: Utility Macros

Exporting & Importing Datasets & Catalogs: Utility Macros Exporting & Importing Datasets & Catalogs: Utility Macros Adel Fahmy, SYSMART Consulting, North Brunswick, NJ ABSTRACT Since different companies use different SAS versions installed on different platforms,

More information

Give me EVERYTHING! A macro to combine the CONTENTS procedure output and formats. Lynn Mullins, PPD, Cincinnati, Ohio

Give me EVERYTHING! A macro to combine the CONTENTS procedure output and formats. Lynn Mullins, PPD, Cincinnati, Ohio PharmaSUG 2014 - Paper CC43 Give me EVERYTHING! A macro to combine the CONTENTS procedure output and formats. Lynn Mullins, PPD, Cincinnati, Ohio ABSTRACT The PROC CONTENTS output displays SAS data set

More information

Useful Tips When Deploying SAS Code in a Production Environment

Useful Tips When Deploying SAS Code in a Production Environment Paper SAS258-2014 Useful Tips When Deploying SAS Code in a Production Environment ABSTRACT Elena Shtern, SAS Institute Inc., Arlington, VA When deploying SAS code into a production environment, a programmer

More information

Techdata Solution. SAS Analytics (Clinical/Finance/Banking)

Techdata Solution. SAS Analytics (Clinical/Finance/Banking) +91-9702066624 Techdata Solution Training - Staffing - Consulting Mumbai & Pune SAS Analytics (Clinical/Finance/Banking) What is SAS SAS (pronounced "sass", originally Statistical Analysis System) is an

More information

Using SAS Files CHAPTER 3

Using SAS Files CHAPTER 3 55 CHAPTER 3 Using SAS Files Introduction to SAS Files 56 What Is a SAS File? 56 Types of SAS Files 57 Using Short or Long File Extensions in SAS Libraries 58 SAS Data Sets (Member Type: Data or View)

More information

Using SAS Macros to Extract P-values from PROC FREQ

Using SAS Macros to Extract P-values from PROC FREQ SESUG 2016 ABSTRACT Paper CC-232 Using SAS Macros to Extract P-values from PROC FREQ Rachel Straney, University of Central Florida This paper shows how to leverage the SAS Macro Facility with PROC FREQ

More information

Developing Data-Driven SAS Programs Using Proc Contents

Developing Data-Driven SAS Programs Using Proc Contents Developing Data-Driven SAS Programs Using Proc Contents Robert W. Graebner, Quintiles, Inc., Kansas City, MO ABSTRACT It is often desirable to write SAS programs that adapt to different data set structures

More information

Level I: Getting comfortable with my data in SAS. Descriptive Statistics

Level I: Getting comfortable with my data in SAS. Descriptive Statistics Level I: Getting comfortable with my data in SAS. Descriptive Statistics Quick Review of reading Data into SAS Preparing Data 1. Variable names in the first row make sure they are appropriate for the statistical

More information

A simplistic approach to Grid Computing Edmonton SAS Users Group. April 5, 2016 Bill Benson, Enterprise Data Scienc ATB Financial

A simplistic approach to Grid Computing Edmonton SAS Users Group. April 5, 2016 Bill Benson, Enterprise Data Scienc ATB Financial A simplistic approach to Grid Computing Edmonton SAS Users Group April 5, 2016 Bill Benson, Enterprise Data Scienc ATB Financial Grid Computing The Basics Points to Cover: Benefits of Grid Computing Server

More information

Introduction to SAS. I. Understanding the basics In this section, we introduce a few basic but very helpful commands.

Introduction to SAS. I. Understanding the basics In this section, we introduce a few basic but very helpful commands. Center for Teaching, Research and Learning Research Support Group American University, Washington, D.C. Hurst Hall 203 rsg@american.edu (202) 885-3862 Introduction to SAS Workshop Objective This workshop

More information

Format-o-matic: Using Formats To Merge Data From Multiple Sources

Format-o-matic: Using Formats To Merge Data From Multiple Sources SESUG Paper 134-2017 Format-o-matic: Using Formats To Merge Data From Multiple Sources Marcus Maher, Ipsos Public Affairs; Joe Matise, NORC at the University of Chicago ABSTRACT User-defined formats are

More information

Leave Your Bad Code Behind: 50 Ways to Make Your SAS Code Execute More Efficiently.

Leave Your Bad Code Behind: 50 Ways to Make Your SAS Code Execute More Efficiently. Leave Your Bad Code Behind: 50 Ways to Make Your SAS Code Execute More Efficiently. William E Benjamin Jr Owl Computer Consultancy, LLC 2012 Topic Groups Processing more than one file in each DATA step

More information

Tracking Dataset Dependencies in Clinical Trials Reporting

Tracking Dataset Dependencies in Clinical Trials Reporting Tracking Dataset Dependencies in Clinical Trials Reporting Binoy Varghese, Cybrid Inc., Wormleysburg, PA Satyanarayana Mogallapu, IT America Inc., Edison, NJ ABSTRACT Most clinical trials study reporting

More information

Formats, Informats and How to Program with Them Ian Whitlock, Westat, Rockville, MD

Formats, Informats and How to Program with Them Ian Whitlock, Westat, Rockville, MD Formats, Informats and How to Program with Them Ian Whitlock, Westat, Rockville, MD Abstract Formats tell how to display stored data and informats how to read them. In other words, they allow the separation

More information

Preserving your SAS Environment in a Non-Persistent World. A Detailed Guide to PROC PRESENV. Steven Gross, Wells Fargo, Irving, TX

Preserving your SAS Environment in a Non-Persistent World. A Detailed Guide to PROC PRESENV. Steven Gross, Wells Fargo, Irving, TX Preserving your SAS Environment in a Non-Persistent World A Detailed Guide to PROC PRESENV Steven Gross, Wells Fargo, Irving, TX ABSTRACT For Enterprise Guide users, one of the challenges often faced is

More information

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

Stat 302 Statistical Software and Its Applications SAS: Data I/O Stat 302 Statistical Software and Its Applications SAS: Data I/O Yen-Chi Chen Department of Statistics, University of Washington Autumn 2016 1 / 33 Getting Data Files Get the following data sets from the

More information

Chapter 6: Modifying and Combining Data Sets

Chapter 6: Modifying and Combining Data Sets Chapter 6: Modifying and Combining Data Sets The SET statement is a powerful statement in the DATA step. Its main use is to read in a previously created SAS data set which can be modified and saved as

More information

Using Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse

Using Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse Paper DM-01 Using Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse Abstract Ben Cochran, The Bedford Group, Raleigh, NC Often SAS users need to access

More information

A SAS Macro for Balancing a Weighted Sample

A SAS Macro for Balancing a Weighted Sample Paper 258-25 A SAS Macro for Balancing a Weighted Sample David Izrael, David C. Hoaglin, and Michael P. Battaglia Abt Associates Inc., Cambridge, Massachusetts Abstract It is often desirable to adjust

More information

Facilitate Statistical Analysis with Automatic Collapsing of Small Size Strata

Facilitate Statistical Analysis with Automatic Collapsing of Small Size Strata PO23 Facilitate Statistical Analysis with Automatic Collapsing of Small Size Strata Sunil Gupta, Linfeng Xu, Quintiles, Inc., Thousand Oaks, CA ABSTRACT Often in clinical studies, even after great efforts

More information

Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse

Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse Ben Cochran, The Bedford Group, Raleigh, NC Abstract Often SAS users need to access data from non- SAS

More information

Avoiding Macros in SAS. Fareeza Khurshed Yiye Zeng

Avoiding Macros in SAS. Fareeza Khurshed Yiye Zeng Avoiding Macros in SAS Fareeza Khurshed Yiye Zeng Macro s Usually used to avoid repetitive code or automate procedures I use them and write them on a regular basis Based on MY experience there s a set

More information

A Mass Symphony: Directing the Program Logs, Lists, and Outputs

A Mass Symphony: Directing the Program Logs, Lists, and Outputs PharmaSUG2011 Paper CC24 ABSTRACT A Mass Symphony: Directing the Program Logs, Lists, and Outputs Tom Santopoli, Octagon Research Solutions, Inc., Wayne, PA When executing programs in SAS, it is efficient

More information

Introduction to STATA

Introduction to STATA Introduction to STATA Duah Dwomoh, MPhil School of Public Health, University of Ghana, Accra July 2016 International Workshop on Impact Evaluation of Population, Health and Nutrition Programs Learning

More information

%Addval: A SAS Macro Which Completes the Cartesian Product of Dataset Observations for All Values of a Selected Set of Variables

%Addval: A SAS Macro Which Completes the Cartesian Product of Dataset Observations for All Values of a Selected Set of Variables %Addval: A SAS Macro Which Completes the Cartesian Product of Dataset Observations for All Values of a Selected Set of Variables Rich Schiefelbein, PRA International, Lenexa, KS ABSTRACT It is often useful

More information

CLS Cohort Studies. Centre for Longitudinal Studies. Data Note 2007/3 CLS. Programming Employment Histories in BCS70 Sweeps 5, 6 and

CLS Cohort Studies. Centre for Longitudinal Studies. Data Note 2007/3 CLS. Programming Employment Histories in BCS70 Sweeps 5, 6 and CLS CLS Cohort Studies Data Note 2007/3 Centre for Longitudinal Studies Programming Employment Histories in BCS70 Sweeps 5, 6 and 7 1996-2004 Kelly Ward Centre for Longitudinal Studies Bedford Group for

More information

Programming Gems that are worth learning SQL for! Pamela L. Reading, Rho, Inc., Chapel Hill, NC

Programming Gems that are worth learning SQL for! Pamela L. Reading, Rho, Inc., Chapel Hill, NC Paper CC-05 Programming Gems that are worth learning SQL for! Pamela L. Reading, Rho, Inc., Chapel Hill, NC ABSTRACT For many SAS users, learning SQL syntax appears to be a significant effort with a low

More information

So Much Data, So Little Time: Splitting Datasets For More Efficient Run Times and Meeting FDA Submission Guidelines

So Much Data, So Little Time: Splitting Datasets For More Efficient Run Times and Meeting FDA Submission Guidelines Paper TT13 So Much Data, So Little Time: Splitting Datasets For More Efficient Run Times and Meeting FDA Submission Guidelines Anthony Harris, PPD, Wilmington, NC Robby Diseker, PPD, Wilmington, NC ABSTRACT

More information

SAS Display Manager Windows. For Windows

SAS Display Manager Windows. For Windows SAS Display Manager Windows For Windows Computers with SAS software SSCC Windows Terminal Servers (Winstat) Linux Servers (linstat) Lab computers DoIT Info Labs (as of June 2014) In all Labs with Windows

More information

USING DATA TO SET MACRO PARAMETERS

USING DATA TO SET MACRO PARAMETERS USING DATA TO SET MACRO PARAMETERS UPDATE A PREVIOUS EXAMPLE %macro report(regs=); %let r=1; %let region=%scan(&regs,&r); %do %until(&region eq ); options nodate pageno=1; ods pdf file="&region..pdf";

More information

Procedures. Calls any BMDP program to analyze data in a SAS data set

Procedures. Calls any BMDP program to analyze data in a SAS data set 219 CHAPTER 15 Procedures SAS Procedures Under UNIX 219 SAS Procedures Under UNIX This chapter describes SAS procedures that have behavior or syntax that is specific to UNIX environments. Each procedure

More information

Taming a Spreadsheet Importation Monster

Taming a Spreadsheet Importation Monster SESUG 2013 Paper BtB-10 Taming a Spreadsheet Importation Monster Nat Wooding, J. Sargeant Reynolds Community College ABSTRACT As many programmers have learned to their chagrin, it can be easy to read Excel

More information

Choosing the Right Procedure

Choosing the Right Procedure 3 CHAPTER 1 Choosing the Right Procedure Functional Categories of Base SAS Procedures 3 Report Writing 3 Statistics 3 Utilities 4 Report-Writing Procedures 4 Statistical Procedures 5 Efficiency Issues

More information

Getting the Most from Hash Objects. Bharath Gowda

Getting the Most from Hash Objects. Bharath Gowda Getting the Most from Hash Objects Bharath Gowda Getting the most from Hash objects Techniques covered are: SQL join Data step merge using BASE engine Data step merge using SPDE merge Index Key lookup

More information

INTRODUCTION to SAS STATISTICAL PACKAGE LAB 3

INTRODUCTION to SAS STATISTICAL PACKAGE LAB 3 Topics: Data step Subsetting Concatenation and Merging Reference: Little SAS Book - Chapter 5, Section 3.6 and 2.2 Online documentation Exercise I LAB EXERCISE The following is a lab exercise to give you

More information

Biostatistics & SAS programming. Kevin Zhang

Biostatistics & SAS programming. Kevin Zhang Biostatistics & SAS programming Kevin Zhang January 26, 2017 Biostat 1 Instructor Instructor: Dong Zhang (Kevin) Office: Ben Franklin Hall 227 Phone: 570-389-4556 Email: dzhang(at)bloomu.edu Class web:

More information

SAS Online Training: Course contents: Agenda:

SAS Online Training: Course contents: Agenda: SAS Online Training: Course contents: Agenda: (1) Base SAS (6) Clinical SAS Online Training with Real time Projects (2) Advance SAS (7) Financial SAS Training Real time Projects (3) SQL (8) CV preparation

More information

Big Data Executive Program

Big Data Executive Program Big Data Executive Program Big Data Executive Program Business Visualization for Big Data (BV) SAS Visual Analytics help people see things that were not obvious to them before. Even when data volumes are

More information

PharmaSUG Paper AD06

PharmaSUG Paper AD06 PharmaSUG 2012 - Paper AD06 A SAS Tool to Allocate and Randomize Samples to Illumina Microarray Chips Huanying Qin, Baylor Institute of Immunology Research, Dallas, TX Greg Stanek, STEEEP Analytics, Baylor

More information

%MAKE_IT_COUNT: An Example Macro for Dynamic Table Programming Britney Gilbert, Juniper Tree Consulting, Porter, Oklahoma

%MAKE_IT_COUNT: An Example Macro for Dynamic Table Programming Britney Gilbert, Juniper Tree Consulting, Porter, Oklahoma Britney Gilbert, Juniper Tree Consulting, Porter, Oklahoma ABSTRACT Today there is more pressure on programmers to deliver summary outputs faster without sacrificing quality. By using just a few programming

More information

0.1 Stata Program 50 /********-*********-*********-*********-*********-*********-*********/ 31 /* Obtain Data - Populate Source Folder */

0.1 Stata Program 50 /********-*********-*********-*********-*********-*********-*********/ 31 /* Obtain Data - Populate Source Folder */ 0.1 Stata Program 1 capture log close master // suppress error and close any open logs 2 log using RDC3-master, name(master) replace text 3 // program: RDC3-master.do 4 // task: Demonstrate basic Stata

More information

22S:166. Checking Values of Numeric Variables

22S:166. Checking Values of Numeric Variables 22S:1 Computing in Statistics Lecture 24 Nov. 2, 2016 1 Checking Values of Numeric Variables range checks when you know what the range of possible values is for a given quantitative variable internal consistency

More information

Tweaking your tables: Suppressing superfluous subtotals in PROC TABULATE

Tweaking your tables: Suppressing superfluous subtotals in PROC TABULATE ABSTRACT Tweaking your tables: Suppressing superfluous subtotals in PROC TABULATE Steve Cavill, NSW Bureau of Crime Statistics and Research, Sydney, Australia PROC TABULATE is a great tool for generating

More information

options nofmterr; ods html close; *STOPS WRITING TO THE CURRENT RESULTS VIEWER;

options nofmterr; ods html close; *STOPS WRITING TO THE CURRENT RESULTS VIEWER; options nofmterr; ods html close; *STOPS WRITING TO THE CURRENT RESULTS VIEWER; ods html; *OPENS A NEW RESULTS VIEWER; /********************************************************** The directory in the libname

More information

Arthur L. Carpenter California Occidental Consultants, Oceanside, California

Arthur L. Carpenter California Occidental Consultants, Oceanside, California Paper 028-30 Storing and Using a List of Values in a Macro Variable Arthur L. Carpenter California Occidental Consultants, Oceanside, California ABSTRACT When using the macro language it is not at all

More information

Best Practices for Loading Autodesk Inventor Data into Autodesk Vault

Best Practices for Loading Autodesk Inventor Data into Autodesk Vault AUTODESK INVENTOR WHITE PAPER Best Practices for Loading Autodesk Inventor Data into Autodesk Vault The most important item to address during the implementation of Autodesk Vault software is the cleaning

More information

Cramped for Drive Space? Save Space with the Auto-Compress Macro

Cramped for Drive Space? Save Space with the Auto-Compress Macro Cramped for Drive Space? Save Space with the Auto-Compress Macro Adam Bemis, Household International, Beaverton, OR Scott Hanson, Household International, Beaverton, OR ABSTRACT Although storage space

More information

The Ugliest Data I ve Ever Met

The Ugliest Data I ve Ever Met The Ugliest Data I ve Ever Met Derek Morgan, Washington University Medical School, St. Louis, MO Abstract Data management frequently involves interesting ways of doing things with the SAS System. Sometimes,

More information

1 Files to download. 3 Macro to list the highest and lowest N data values. 2 Reading in the example data file

1 Files to download. 3 Macro to list the highest and lowest N data values. 2 Reading in the example data file 1 2 22S:172 Lab session 10 Macros for data cleaning July 17, 2003 GENDER VISIT HR SBP DBP DX AE = "Gender" = "Visit Date" = "Heart Rate" = "Systolic Blood Pressure" = "Diastolic Blood Pressure" = "Diagnosis

More information

Using a Fillable PDF together with SAS for Questionnaire Data Donald Evans, US Department of the Treasury

Using a Fillable PDF together with SAS for Questionnaire Data Donald Evans, US Department of the Treasury Using a Fillable PDF together with SAS for Questionnaire Data Donald Evans, US Department of the Treasury Introduction The objective of this paper is to demonstrate how to use a fillable PDF to collect

More information

A Macro that can Search and Replace String in your SAS Programs

A Macro that can Search and Replace String in your SAS Programs ABSTRACT MWSUG 2016 - Paper BB27 A Macro that can Search and Replace String in your SAS Programs Ting Sa, Cincinnati Children s Hospital Medical Center, Cincinnati, OH In this paper, a SAS macro is introduced

More information

April 4, SAS General Introduction

April 4, SAS General Introduction PP 105 Spring 01-02 April 4, 2002 SAS General Introduction TA: Kanda Naknoi kanda@stanford.edu Stanford University provides UNIX computing resources for its academic community on the Leland Systems, which

More information

Using SAS software to fulfil an FDA request for database documentation

Using SAS software to fulfil an FDA request for database documentation Using SAS software to fulfil an FDA request for database documentation Introduction Pantaleo Nacci, Adam Crisp Glaxo Wellcome R&D, UK Historically, a regulatory submission to seek approval for a new drug

More information

ABSTRACT DATA CLARIFCIATION FORM TRACKING ORACLE TABLE INTRODUCTION REVIEW QUALITY CHECKS

ABSTRACT DATA CLARIFCIATION FORM TRACKING ORACLE TABLE INTRODUCTION REVIEW QUALITY CHECKS Efficient SAS Quality Checks: Unique Error Identification And Enhanced Data Management Analysis Jim Grudzinski, Biostatistics Manager Of SAS Programming Covance Periapproval Services Inc, Radnor, PA ABSTRACT

More information

Wonderful Unix SAS Scripts: SAS Quickies for Dummies Raoul Bernal, Amgen Inc., Thousand Oaks, CA

Wonderful Unix SAS Scripts: SAS Quickies for Dummies Raoul Bernal, Amgen Inc., Thousand Oaks, CA PharmaSUG2010 - Paper CC25 Wonderful Unix SAS Scripts: SAS Quickies for Dummies Raoul Bernal, Amgen Inc., Thousand Oaks, CA ABSTRACT Repeated simple SAS jobs can be executed online and in real-time to

More information

Using SAS 9.4M5 and the Varchar Data Type to Manage Text Strings Exceeding 32kb

Using SAS 9.4M5 and the Varchar Data Type to Manage Text Strings Exceeding 32kb ABSTRACT Paper 2690-2018 Using SAS 9.4M5 and the Varchar Data Type to Manage Text Strings Exceeding 32kb John Schmitz, Luminare Data LLC Database systems support text fields much longer than the 32kb limit

More information

Creating a data file and entering data

Creating a data file and entering data 4 Creating a data file and entering data There are a number of stages in the process of setting up a data file and analysing the data. The flow chart shown on the next page outlines the main steps that

More information

Automating Comparison of Multiple Datasets Sandeep Kottam, Remx IT, King of Prussia, PA

Automating Comparison of Multiple Datasets Sandeep Kottam, Remx IT, King of Prussia, PA Automating Comparison of Multiple Datasets Sandeep Kottam, Remx IT, King of Prussia, PA ABSTRACT: Have you ever been asked to compare new datasets to old datasets while transfers of data occur several

More information

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

Using SAS to Analyze CYP-C Data: Introduction to Procedures. Overview Using SAS to Analyze CYP-C Data: Introduction to Procedures CYP-C Research Champion Webinar July 14, 2017 Jason D. Pole, PhD Overview SAS overview revisited Introduction to SAS Procedures PROC FREQ PROC

More information

The Three I s of SAS Log Messages, IMPORTANT, INTERESTING, and IRRELEVANT William E Benjamin Jr, Owl Computer Consultancy, LLC, Phoenix AZ.

The Three I s of SAS Log Messages, IMPORTANT, INTERESTING, and IRRELEVANT William E Benjamin Jr, Owl Computer Consultancy, LLC, Phoenix AZ. ABSTRACT Paper TT_14 The Three I s of SAS Log Messages, IMPORTANT, INTERESTING, and IRRELEVANT William E Benjamin Jr, Owl Computer Consultancy, LLC, Phoenix AZ. I like to think that SAS error messages

More information