Announcement Icon Online training class for Clinical R programming batch starts on Monday, 02Feb2026. Click here for details.

Export data to Excel workbook


Lesson Description
-
  • Use PROC EXPORT in SAS to write an Excel file.
  • In R, use writexl to create .xlsx files.
  • Update file paths to your local machine.
proc export data=males outfile="path\\males_export.xlsx" replace;
run;
  • PROC EXPORT writes the SAS dataset to an Excel file.
library(writexl)

write_xlsx(males, "path/males_writexlsx.xlsx")

write_xlsx(list(class = class, Males = males), "path/multisheets_writexlsx.xlsx")
  • write_xlsx() writes a data frame to an .xlsx file.
  • Use a named list to create multiple sheets.
library(writexl)

write_xlsx(males, "path/males_writexlsx.xlsx")
  • Base R can use writexl to export .xlsx files.