A SAS Macro/R Code Comparison: Generating Multiple Datasets by Tristan Hayes


This is a short comparison of SAS and R code in the context of generating multiple datasets. In this example, the mpg dataset from R is used to show how one might use a SAS Macro to subset the data by car class, followed by the R equivalent. You will see that in SAS, the macro is a little complicated; however, in R, the macro only takes a few lines to accomplish the same task.

First, the SAS Code.

*Get the Unique list of car classes;
proc sql;
 create table class as select distinct class
 from mpg;

%macro Subset_Data();
*Open the list of car classes, and go from the first item to the last in the list;
%do i= 1 %to &SYSNOBS.;
 *&SYSNOBS takes on the value of the length last dataset processed by SAS;
 data null;
  set class;
  if n=&i.;
  call symput(‘name’, class);
  *symput saves the value of class as the macro variable &name.;

*Subset the data;
 data dataset_&name.;
  set mpg;
  where class=“&name.”;

%mend Subset_Data;

Now the R Code

Here the R equivalent to the do loop is a for loop. The proc sql code used to generate a unique list of car classes is replaced by simply unique(mpg$class).

for (var in unique(mpg$class)) {
  assign(paste("dataset",var,sep="_"), mpg[which(mpg$class == var), ])


With the SAS code, the naming of the datasets was handled by loading a dataset and passing the value for a specific observation to the macro. In R, the assign function handles naming the dataset generated by the code mpg[which(mpg$class == var), ].

UTHSC and Memphis VA Key Participants in SPRINT MIND Study Showing Link Between Low Blood Pressure and Reduced Risk of Mild Cognitive Impairment

Leaders of the Memphis sites for the national SPRINT MIND clinical trial are, from left, Karen C. Johnson, MD, MPH; William Cushman, MD; Barry Wall, MD; Catherine Womack, MD; Linda Nichols, PhD; and Jennifer Martindale-Adams, EdD. (Photo by Connor Bran/UTHSC)


Researchers at the University of Tennessee Health Science Center (UTHSC) and the Memphis Veterans Affairs (VA) Medical Center were part of the SPRINT MIND (Systolic Blood Pressure Intervention Trial Memory and Cognition IN Decreased Hypertension) multisite clinical trial, which released study findings today showing that intensive lowering of blood pressure reduced the risk of mild cognitive impairment (MCI), a known risk factor for dementia.

Mild cognitive impairment causes difficulty with cognition, thinking, remembering, and reasoning that is greater than expected with normal aging. Dementia is a more severe form of loss in cognitive functions that reduces a person’s ability to perform everyday tasks. Hypertension, or high blood pressure, is very common in adults age 50 and older and is a leading risk factor for heart disease, stroke, and kidney failure. A growing body of research suggests that hypertension has been identified as a potentially modifiable risk factor for MCI and dementia.

Launched in 2010 by the National Heart, Lung, and Blood Institute (NHLBI) of the National Institutes of Health (NIH), SPRINT enrolled more than 9,300 adults age 50 and older with hypertension who were at a high risk for cardiovascular disease. They were recruited from approximately 102 medical centers and clinical practices throughout the United States and Puerto Rico.

Memphis hosts two SPRINT study sites, one at UTHSC and one at the Memphis VA Medical Center. UTHSC’s site, which followed 175 participants, was led by Karen C. Johnson, MD, MPH, principal investigator, College of Medicine Endowed Professor in Women’s Health, and professor of Preventive Medicine at UTHSC, and Catherine Womack, MD, associate professor in the Department of Preventive Medicine and co-chief of the Division of Internal Medicine in the College of Medicine at UTHSC.

The Memphis VA Medical Center, which served as a VA Network hub and clinical site, followed 1,660 participants at 25 VA medical centers within the SPRINT Veterans Affairs Clinical Center Network (CCN). William Cushman, MD, chief of Preventive Medicine at the Memphis VA, and professor of Preventive Medicine, Medicine, and Physiology at UTHSC, serves as the principal investigator for the VA Network. Dr. Barry Wall, also from the Memphis VA, is the co-principal investigator for the SPRINT VA Clinical Center Network (CCN) and principal investigator for the VA Memphis SPRINT clinical site that recruited 80 veterans for SPRINT. Linda Nichols PhD, professor, and Jennifer Martindale-Adams, EdD, associate professor in the Department of Preventive Medicine at UTHSC, were VA CCN consultants and also co-principal investigators for the SPRINT MIND study.

The SPRINT MIND study, an essential component of the umbrella SPRINT study, aimed to address whether aggressive blood pressure control would also reduce the risk of developing dementia and cognitive impairment. The study results show that treating blood pressure to a goal of less than 120 mm Hg does not statistically reduce the risk of dementia, but does significantly reduce the risk of developing MCI. Authors of the SPRINT MIND study conclude that this result may have been due to fewer cases of dementia occurring during the study.

“The SPRINT MIND study has shown for the first time that intensive control of blood pressure in older people significantly reduced the risk of developing mild cognitive impairment, a precursor of early dementia,” said Dr. Johnson, who also served as the vice chair of the National Steering Committee for the SPRINT study. “This is a very important finding, as it may reduce concerns that many clinicians had that lower systolic blood pressure in older persons might be harmful to their brain.”

The Alzheimer’s Association has agreed to fund additional follow-up of SPRINT MIND participants in the hope that sufficient dementia cases will accrue, allowing for a more definitive statement on these study outcomes. Dr. Nichols is encouraged by the association’s commitment to help provide more conclusive study results.
“We are thrilled that the Alzheimer’s Association will be working with us to continue to follow SPRINT MIND participants,” Dr. Nichols said. “We may be able to determine if intensive blood pressure control will reduce dementia in addition to mild cognitive impairment.”

In August 2015, the SPRINT trial was stopped earlier than planned when the beneficial effects of intensive blood pressure management on mortality and cardiovascular disease were discovered. The SPRINT MIND findings provide promise that individuals can take steps to lower their risk of mild cognitive impairment and dementia, and it could be as easy as lowering their blood pressure.

“The fact that cognition and dementia were not worsened and there were even some improvements is very encouraging in light of the impressive improvement in cardiovascular outcomes with intensive blood pressure lowering in SPRINT,” Dr. Cushman said.

“These findings provide hope to anyone who is concerned about developing memory problems,” Dr. Martindale-Adams said.
SPRINT study findings have already had a world-wide impact on how people define hypertension and how doctors treat hypertension. The American College of Cardiology and the American Heart Association published new blood pressure guidelines in 2017 based on SPRINT data. The SPRINT MIND study results were reported in the Jan. 28, 2019 edition of the Journal of the American Medical Association.

This is a reprint of the original article by Sarah Ashley Fenderson.

Two Teams of Multi-State Investigators Chosen as Collaborative Health Disparities Research Award Winners


The Delta Clinical and Translational Science Consortium has chosen two research teams as the 2018 Collaborative Research Network (CORNET) Awards in Health Disparities Research winners. The CORNET Awards in Health Disparities Research were created by leaders within the consortium to stimulate innovative, interdisciplinary, team-based health disparities research that involves investigators from the University of Tennessee Health Science Center (UTHSC), Tulane University, and the University of Mississippi Medical Center (UMMC). The purpose of the awards is to give seed funding, up to $75,000 per project, to collaborative research teams working to combat regional health inequities faced by those living in the Delta South.

“Through the work that the Delta Consortium is doing, we know there is an increased interest among our researchers to find solutions to complex health issues faced by people in our region,” said Steven R. Goodman, PhD, vice chancellor for Research at UTHSC. “The high response to the CORNET Awards opportunity and the potential impact the two winning projects will have for our community members is overwhelming. I congratulate all the selected collaborative team members.”

Continue reading…

Inaugural Collaborative Health Disparities Conference Aims to Combat Regional Health Inequities for Southerners


Nearly 200 researchers from the University of Tennessee Health Science Center, Tulane University, and the University of Mississippi Medical Center (UMMC) gathered on Thursday, July 19 for the Delta Clinical and Translational Health Disparities Conference.

Envisioned by Steven R. Goodman, PhD, vice chancellor for Research at UTHSC, Richard L. Summers, MD, vice chancellor for Research at UMMC, and Laura S. Levy, PhD, vice president for Research at Tulane, the conference was designed to bring together health disparities researchers from UTHSC with those from UMMC and Tulane, allowing them to share their research interests, and catalyze new collaborative partnerships that will result in the submission of a UTHSC/TU/UMMC Collaborative Research Network (CORNET) Award proposal in Health Disparities Research.

Continue Reading…

New UTHSC Tennessee Clinical and Translational Science Institute Established to Improve Human Health for Southerners


Researchers at the University of Tennessee Health Science Center have formed the Tennessee Clinical and Translational Science Institute (TN-CTSI) to address health inequities in the Southern United States.

According to the U.S. Census Bureau, the American South represented the largest population growth by region in 2017. Comprised of 17 states stretching from Texas, Oklahoma, and Arkansas on the west, to the Atlantic Ocean on the east, and northward to Delaware, Maryland, Kentucky, and West Virginia, the South has a large minority population with heightened levels of poverty and health disparities.

“TN-CTSI will catalyze the development of methods and technologies that lead to more efficient translation of medical discoveries into interventions that improve human health across the translational research spectrum, from basic science to population science,” said Karen C. Johnson, MD, MPH, co-leader of TN-CTSI and Endowed Professor of Women’s Health in the UTHSC Department of Preventive Medicine. “Our mission is to improve the health of Tennesseans and underserved populations in the South by providing education and training, fostering interdisciplinary teams, improving quality and efficiency, and engaging community stakeholders and partners in meaningful collaboration.”

Continue Reading…