A little announcement. A lot to explore.

Happy learning!

Explore lessons, including SAS & R programs and practice data.

Search lessons

Type at least 3 characters to see matching lessons.

Open SAS ↗Open R ↗
← SASnRConvert all the variable names to uppercase

Introduction

  • In clinical programming, variable names are often ALL CAPS to match SDTM and ADaM conventions (USUBJID, STUDYID, ADSL, and so on).
  • When we import data from CSV, Excel or an external vendor, the names rarely arrive uppercase — we have to force them ourselves.
  • SAS gives us the options validvarname=upcase; global setting that makes every variable name uppercase from the point it is set.
  • R has no global option like this, but rename_with(toupper) (tidyverse) or a direct assignment to names() (base R) does the same job at the dataset level.
  • This lesson shows how to normalise all column names to uppercase after reading in a dataset.
  • After running, every column name in the output is ALL CAPS.

Convert all the variable names to uppercase