Introduction to R for SAS programmers

Author

Sadchla Mascary, Stefan Thoma, Zelos Zhu, Thomas Neitmann

Published

1/23/23

About

On this page you find the materials used in the workshop Introduction to R for SAS programmers taking place on January 17th, 2023. The recording of the workshop is available on the CDISC website.

The workshop provided an RStudio cloud work-space. To follow along on your local machine, create a new R-Project and paste / execute the following code-chunk in an R-Script or the R console. Executing the following chunk in R on your machine will create and populate a data folder in your current working directory.

# set paths and data names
external.path <- 
  "https://github.com/pharmaverse/intro-to-r-for-sas-programmers-workshop/blob/main/data"

local.path <- ("data")
subdir <- file.path(local.path, "save_data")
files <- c(
  "adsl.RData", 
  "adsl.csv", 
  "adsl.sas7bdat", 
  "adsl_1.RData", 
  "adsl_2.RData", 
  "ae.rds", 
  "dm.rds", 
  "ds.rds",
  "ex.rds",
  "suppdm.rds",
  "suppds.rds"
  )

# external files (with path)
urls <- file.path(external.path, paste(files, "raw=true", sep = "?"))
# local files (with path)
dest <- file.path(local.path, files)

# create data folder in wd
if (!file.exists(local.path)) {
  dir.create(local.path)
  # subdirectory
  dir.create(subdir)
}

# download files if needed
download.file(urls, destfile = dest)

Further material

You can’t get enough? Here is a resource to help transitioning from SAS to R.