Manage Variable Lists with Macro Variables 1 for Improved Readability and Modifiability.

Slides:



Advertisements
Similar presentations
How SAS implements structured programming constructs
Advertisements

The Regression Equation  A predicted value on the DV in the bi-variate case is found with the following formula: Ŷ = a + B (X1)
1 Eliminate Cookie-Cutter Code with %wordLoop 1
Geometric Random Variables Target Goal: I can find probabilities involving geometric random variables 6.3c h.w: pg 405: 93 – 99 odd,
Chicago Insurance Redlining Example Were insurance companies in Chicago denying insurance in neighborhoods based on race?
Multiple Linear Regression
Propensity Score Matching Lava Timsina Kristina Rabarison CPH Doctoral Seminar Fall 2012.
Nearest neighbor matching USING THE GREEDY MATCH MACRO Note: Much of the code originally was written by Lori Parsons
Multiple Logistic Regression RSQUARE, LACKFIT, SELECTION, and interactions.
Some Terms Y =  o +  1 X Regression of Y on X Regress Y on X X called independent variable or predictor variable or covariate or factor Which factors.
Assignmnet: Simple Random Sampling With Replacement Some Solutions.
Assignmnet: Simple Random Sampling With Replacement Some Solutions.
Chapter 5 Data Manipulation and Transaction Control Oracle 10g: SQL
Chapter 18: Modifying SAS Data Sets and Tracking Changes 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Computing for Research I Spring 2014 January 22, 2014.
STATA User Group September 2007 Shuk-Li Man and Hannah Evans.
Chapter Outline 5.0 PROC GLM
STAT 3130 Statistical Methods II Missing Data and Imputation.
A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.
X 11 X 12 X 13 X 21 X 22 X 23 X 31 X 32 X 33. Research Question Are nursing homes dangerous for seniors? Does admittance to a nursing home increase risk.
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.
Adventures in ODS: Producing Customized Reports Using Output from Multiple SAS® Procedures Stuart Long Westat, Durham,
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
The Practice of Social Research Chapter 14 – Quantitative Data Analysis.
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 Weighted Data Donald Miller Population Research Institute 812 Oswald Tower, December 2008.
1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University.
Regression in SAS Caitlin Phelps. Importing Data  Proc Import:  Read in variables in data set  May need some options incase SAS doesn’t guess the format.
Topic 13: Multiple Linear Regression Example. Outline Description of example Descriptive summaries Investigation of various models Conclusions.
1 Experimental Statistics - week 14 Multiple Regression – miscellaneous topics.
Lecture 3 Topic - Descriptive Procedures Programs 3-4 LSB 4:1-4.4; 4:9:4:11; 8:1-8:5; 5:1-5.2.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 6 Switchboards, PivotTables, and PivotCharts.
Tips & Tricks From your fellow SAS users 9/30/2004.
Lesson 4 - Topics Creating new variables in the data step SAS Functions.
Copyright © 2010, SAS Institute Inc. All rights reserved. SAS ® Using the SAS Grid.
Lesson 8 - Topics Creating SAS datasets from procedures Using ODS and data steps to make reports Using PROC RANK Programs in course notes LSB 4:11;5:3.
Chapter 7: Macros in SAS  Macros provide for more flexible programming in SAS  Macros make SAS more “object-oriented”, like R 1 © Fall 2011 John Grego.
PSY6010: Statistics, Psychometrics and Research Design Professor Leora Lawton Spring 2007 Wednesdays 7-10 PM Room 204.
Slide 12.1 Saunders, Lewis and Thornhill, Research Methods for Business Students, 5 th Edition, © Mark Saunders, Philip Lewis and Adrian Thornhill 2009.
Applied Algebra B Lesson: 3 – 3 Mean, Median, Mode, & Range Objective: Learn to find the mean, median, & mode and range of a set of data.
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.
Multiple Imputation using SAS Don Miller 812 Oswald Tower
01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.
Chapter 8: Using Basic Statistical Procedures “33⅓% of the mice used in the experiment were cured by the test drug; 33⅓% of the test population were unaffected.
Preparing to collect data. Make sure you have your materials Surveys –All surveys should have a unique numerical identifier on each page –You can write.
Testing Significance of coefficients Usually, first examination of model Does the model including the independent variable provide significantly more information.
Solve Equations With Variables on Both Sides. Steps to Solve Equations with Variables on Both Sides  1) Do distributive property  2) Combine like terms.
1 Take a challenge with time; never let time idles away aimlessly.
Introduction to Dot Plots. There are two types of data we will be looking at Categorical Data - places someone or something into several groups or categories.
Four way analysis Nursing home residence Gender Age Death.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
Multiple Imputation using SAS Don Miller 812 Oswald Tower
QM222 Class 13 Section D1 Omitted variable bias (Chapter 13.)
SAS Macro Language.
Advanced Analytics Using Enterprise Miner
Introduction Introduction to Stata 2016.
Chapter 14 Quantitative Data Analysis
Quick Data Summaries in SAS
Retrieving Macro Variables in the DATA Step
Examining model stability, an example
Passing Simple and Complex Parameters In and Out of Macros
Let’s continue to review some of the statistics you’ve learned in your first class: Bivariate analyses (two variables measured at a time on each observation)
Chp 7 Logit Models for Multivariate Responses
Let’s review some of the statistics you’ve learned in your first class: Univariate analyses (single variable) are done both graphically and numerically.
Why We Need Car Parking Systems - Wohr Parking Systems
Types of Stack Parking Systems Offered by Wohr Parking Systems
Add Title.
Presentation transcript:

Manage Variable Lists with Macro Variables 1 for Improved Readability and Modifiability

The Problem/Opportunity Lists of variables occur frequentlyLists of variables occur frequently Hard for others to read/verifyHard for others to read/verify Samenesses/differences not apparentSamenesses/differences not apparent Often have sublists and variationsOften have sublists and variations

Proposed Solution Assign each sublist to a macro variableAssign each sublist to a macro variable Name the macro variables informativelyName the macro variables informatively Use as needed in executable codeUse as needed in executable code Manipulate macroed string for alterationsManipulate macroed string for alterations

Example Code 4 Title1 Explore distributions of independent variables; proc freq data=ChemoData; table race gender region prevCancer stage grade insur/missing;...; proc univariate data=ChemoData; var age BMI dateDiag income; histogram;...

Example Code (2) 5 Title1 Check for multicolinearity; proc reg data=ChemoData; model chemoRecvd = age BMI dateDiag income/vif; Title1 Perform logistic regression; proc logistic data=ChemoData simple desc; class race gender region prevCancer stage grade insur /param=ref desc; model chemoDi = race gender region prevCancer stage grade insur age BMI dateDiag income /scale=none rsq lackfit;

Assign the Lists 6 %let cateVars=race gender region prevCancer stage grade insur; %let contVars=age BMI dateDiag income;...

Example Code 7 Title1 Explore distributions of independent variables; proc freq data=ChemoData; table &cateVars /missing;...; proc univariate data=ChemoData; var &contVars; histogram;...

Example Code 8 Title1 Check for multicolinearity in continuous IVs; proc reg data=ChemoData; model chemoRecvd = &contVars /vif; run; Title1 Perform logistic regression; proc logistic data=ChemoData simple desc; class &cateVars /param=ref desc; model chemoDi = &cateVars &contIndVars /scale=none rsq lackfit

Handling Alterations/Variations Change the number of categories used for a variableChange the number of categories used for a variable Drop uninformative variablesDrop uninformative variables Add variables for portion of analysisAdd variables for portion of analysis => Can do all of these without cut/paste=> Can do all of these without cut/paste => Can make the alterations explicit=> Can make the alterations explicit

Replacing a Variable 10 %macro replaceWord( /*in macro string */ inStr=, /*list of words altered*/ swapOut= /*word replaced list*/, swapIn=, /*replacement word*/ resMacVar= /*macvar receiving result*/ ); %let newList=; *Use just 2 race categor; %replaceWord(inStr=&cateVars,swapOut=race, swapIn=race2c, resMacVar=newList);

Removing Variables 11 %macro removeWords( wordList=, /*words to remove*/ inMacVar=, /*list of words to alter*/ outMacVar= /*result list of words*/ ); %let newList=; *Drop uninformative vars; %removeWords(wordList=race insur, inMacVar=cateVars, outMacVar=newList);

Take Aways Long list of vars need occur only once Readability benefits when lists are named Modifiability benefits when occur only once Both benefit when alterations are explicit Just do it!

For More Information