Not too familiar with sas, and fair warning, this forum is probably not the ideal place to help with sas code. For help there, check out https://communities.sas.com/
In R, a popular package to help you import Excel files is the readxl package.
Their docs recommend the following packages to help with exporting,
Writing Excel files : The example files datasets.xlsx and datasets.xls (Examples were discussed here https://readxl.tidyverse.org/) were created with the help of openxlsx (and Excel). openxlsx provides “a high level interface to writing, styling and editing worksheets”.
l <- list(iris = iris, mtcars = mtcars, chickwts = chickwts, quakes = quakes)
openxlsx::write.xlsx(l, file = "inst/extdata/datasets.xlsx")
writexl is a new option in this space.... It’s a portable and lightweight way to export a data frame to xlsx, based on libxlsxwriter. It is much more minimalistic than openxlsx, but on simple examples, appears to be about twice as fast and to write smaller files.
All those packages have nice docs. If you're having trouble, I'd suggest a follow-up topic with a reprex to show folks exactly where you're having trouble.