Appointments Jobs About Search Education & Research Clinical Trials Health Information Medical Services

personnel directory

more pages

Locally Written SAS Macros

These SAS macros were written locally and are maintained by Mayo Clinic staff. They contain the SAS source code, a brief description of the macro's function and an example of the macro call.

Copyright 2005 Mayo Foundations for Medical Education and Research. This software is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

These macros are distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Credit where credit is due. If you use functions from Mayo Clinic, please acknowledge the original contributor of the material.

General

bnmlci

  

Exact confidence intervals for a proportion. This macro calculates exact binomial confidence intervals for the binomial parameter P, after having observed X successes in N trials. Output includes normal and poisson approximation to the binomial. Erik Bergstralh [28/AUG/2008]

boot

  

Macro for selecting bootstrap samples. Erik Bergstralh [28/AUG/2008]

comprisk

  

Performs Cumulative Incidence in presence of competing risks. E. Bergstralh [29/AUG/2008]

cutpoint

  

This macro is designed to find a best cutpoint of a continous variable based on chi-square statistics for a binary outcome.

dist

  

Estimates the distance matrix between two groups (e.g. cases and potential controls) on the basis of a set of X's. The macro has an optional call to the VMATCH macro which allows one to perform variable optimal matching. Requires VMATCH if you wish to use the optimal matching option. This macro is designed to find a best cutpoint of a continuous variable based on chi-square statistics for a binary outcome. This macro also requires that you download nobs. Erik Bergstralh & Jon Kosanke [27/Nov/2003]

findcut

  

Finds the best cutpoint of a continuous variable based on the log-rank statistic. Jay & Sumithra Mandrekar, Steve Cha [21/APR/2003]

gmatch

  

Computerized matching of cases to controls using the greedy matching algorithm with a fixed number of controls per case. Controls may be matched to cases using one or more factors (X's). Erik Bergstralh & Jon Kosanke [31/Oct/2003]

jitplot

  

Produce Gplot of continuous variable(y-axis) vs a group variable(x-axis) in such a way that no points are hidden. This type of plot is most effective when N is not large and you wish to display all of the data points. Erik Bergstralh [29/AUG/2008]

match

  

Computerized matching of cases to potential controls. The purpose of this macro is to match 1 or more controls (from a total of M) for each of N cases. The controls may be matched to the cases by one or more factors(X's). ( Replaced July 2003 by GMATCH, VMATCH, and DIST macros.) Jon Kosanke & Erik Bergstralh [28/OCT/1999]

mccc

  

Computes Lin's concordance correlation coefficient (CCC) for any number of raters. Ross Dierkhising [18/Jul/2006]

mcstrat

  

This macro analyzes case-control studies where cases and controls are matched. It is a replacement for the SAS Version 5 procedure PROC MCSTRAT. Rob Vierkant & Jon Kosanke [21/FEB/2000]

plotcorr

  

Proc Plot with correlation/regression statistics appended. This macro will produce a Y*X scatter plot with correlation and regression data appended at the bottom of the page. The macro can use either plot of Gplot. For Gplot the graph can optionally include the regression line of Y on X along with confidence limits for either mean Y or individual predicted Y's. Erik Bergstralh [28/AUG/2008]

plotmat

  

Create a scatterplot matrix graphically displaying the bivariate relationships between a number of variables. Rob Vierkant [9/APR/2003]

regress

  

Summary of association between X and Y. This macro performs ploynomial regression analysis on Xvar with the option of first eliminating outliers. It provides descriptive statistics on Xvar and Yvar and performs tests of modeling assumptions. C. D. STERTZ & Susanne L. Daood [11/MAR/1994]

senspe

  

Calculate sensitivity, specificity, PPV, and NPV with appropriate confidence intervals. Stephen Cha and Stephanie Bagniewski [18/AUG/2005]

vmatch

  

Computerized matching of cases to controls using variable optimal matching. The number of controls per case is allowed to vary with only the total fixed. Controls may be matched to cases using one or more factors (X's). VMATCH uses the case/controls distance matrix as input. This distance matrix can be calculated using the DIST macro, which includes an optional call to VMATCH. Erik Bergstralh & Jon Kosanke [28/OCT/2003]

Survival Analysis

criskcox

  

Competing risk survival analysis with covariates. Walter Kremers, Erik Bergstralh & Terry Therneau [9/Mar/2009]

daspline

  

For a given list of variables, generates formulas for dummy variables that allow fitting of Stone and Koo's additive splines constrained to be linear in the tails. Called by macro schoen. Frank E. Harrell, Jr. [10/MAY/1991]

phlev

  

Leverage residuals for proportional hazards model. This macro returns the leverage residuals matrix L for a proportional hazards model. The returned residuals data set is n by p, where n is the number of (non-missing) subjects used in the PHREG fit, and p is the number of fitted covariates. The leverage residuals are an approximation to the jackknife; the i-th observation of the data set contains the approximate change in beta if observation i were dropped from the model. These residuals will normally be plotted as an aid to finding influential or "high leverage" observations.The procedure can also estimate the robust covariance estimate L'L. Terry Therneau, Erik Bergstralh & Jon Kosanke [11/JAN/2002]
In SAS version 8.1 the %phlev macro is no longer necessary. Robust variance estimates are available directly from phreg using the covsandwich option.

schoen

  

Schoenfeld residuals for proportional hazards model. This macro returns Schoenfeld residuals and scaled Schoenfeld residuals from the Cox model. The Schoenfeld residuals(r) are defined only at event times. Erik Bergstralh, Terry Therneau & Ryan Lennon [20/Mar/2009].

surv

  

Complete Kaplan-Meier survival analysis with printing options and logrank statistic. This macro will calculate the general survival statistics (p(t), standard error, confidience limits, and median survival time. It will also do the k-sample logrank and plotting upon request. Terry Therneau & Jan Offord [21/DEC/1999]

survcstd

  

Calculates the c-statistic (concordance, discrimination index) for survived data with time dependant covariates and corresponding SE and 100(1-alpha)% CI. Walter Kremers [18/SEPT/2008]

survlrk

  

Calculates logrank statatistics for the surv macro. Returns an output dataset. David J. Camp, modifications by Erik Bergstralh & Jan Offord [23/SEP/1993]

survtd

  

General survival statistics p(t), standard error, confidience limits, and median survival time, for the following special cases: 1) Left-truncated survival 2) Time dependant calculations where a person can change state (CLASS) after time zero. This macro does not do any testing or support multiple event data. Terry Therneau & Jan Offord [27/AUG/1997]