SPSS Statistics

 View Only

 Struggling with R in SPSS

Jump to  Best Answer
Georgina Naylor's profile image
Georgina Naylor posted Fri July 11, 2025 09:24 AM

I would really appreciate some help if anyone is able.

I am trying to run competing risk survival analysis (dataset of cancer patients with novel baseline test trying to see if baseline test predictive for outcomes) and have read that I can use fine and gray in SPSS using R.

I have been trying for HOURS to get R to work in SPSS.

I have SPSS Stats 28.0.1, I have downloaded the correct version of R (4.0 - after having downloaded the wrong one first). I have run all the extensions in the hub I can find to do with R, but when I try to run "BEGIN PROGRAM R"...Nothing happens, or I get _SLINE OFF or _SLINE 0 3.

This is a hugely steep learning curve for me - I've been using SPSS fairly basically for a while, but R is totally alien. I am totally lost, so any (very basically explained please) advice/tips would be so very gratefully received.

Thanks,

Georgie

Jon Peck's profile image
Jon Peck IBM Champion  Best Answer

For starters, there is a Competing Risks Survival Regression extension available from the Extension Hub.  It is implemented in R, but you would run it like normal SPSS syntax via Analyze > Survival > Competing Risks Regression.  You don't write any R code in that case.

The error messages you are getting for your R code suggest that something is not closed in your program.  Restarting SPSS is one way to resolve that.  Beyond that, you would need to post your R code for a diagnosis.

Typically you would use the GetDataFromSPSS to load the variables and then have a library call for cmprsk followed by invoking that.function.

Art Jack's profile image
Art Jack

if you're using R blocks you need to make sure all of the libraries are present within the SPSS installation.  You can install them using Jon's R / Python install module from the hub.  You also need to pass the SPSS data frame into R & any changes you attempt won't show up there you'll need to print them out.

Georgina Naylor's profile image
Georgina Naylor

Thanks Jon, that was such a help. I hadn't realised I could work thru the competing risks survival analysis without using R syntax. This is a huge relief as I am rubbish at it!

I have tried to use the CMPRISK bundle just now, but had an error message:  CMPRSK package "could not be loaded" - I have uninstalled the extension and reinstalled, but had same problem again...any ideas? It would be so great to get this done!

Thanks,

Georgie p.s. apologies I've replied to myself - couldn't figure out how to reply to you on the thread...

Jon Peck's profile image
Jon Peck IBM Champion

I presume that you have installed the STATS COMPRISK command from the Extension Hub.  When you run that, it will load some R packages that should have been installed when you did the COMPRISK installation, including packages that are used indirectly by the extension.

The error message should have specified what package failed to load, so post that information.   The main package is cmprsk, but it uses the survival package indirectly.