How to save SAS data into RData format

I have already import dataset but cannot save into RData format. code given below.


save(fiji, file = "fiji_sas.RData")

Please advise

Hi! Welcome!

Have you posted all of your code? If so, then I think you're missing a step. Your code downloads the file Dataset-fiji_sas.sas5bdat to C:/Users/atamani/Desktop/Mydata/Dataset-fiji_sas.sas5bdat. but it doesn't otherwise load or import that file into R. So when you go to save an .RData file, there is no fiji object to be saved, since no fiji object has been created yet by your code. You need to write code that will import the downloaded file into an object called fiji (this would go between the downloading step and the saving step).

P.S. Around here, we encourage people to format their code as code, since it makes it easier to read. You can read about how to do so in this FAQ, or just use the </> button at the top of the post editing box :slightly_smiling_face:

As @jcblum mentioned, the download.file() only saves a copy of the file at the chosen path. If you want to load a SAS dataset as a data.frame, you can use the haven package after downloading the file:

## Install haven if you don't have it:
# install.packages("haven")
fiji <- read_sas(local)
save(fiji, file = "fiji_sas.RData")
1 Like