How can I transpose REDCap longitudinal data in SPSS or R?

Q: A data file exported from a REDCap longitudinal project may contain many data rows for a given record. I wonder if someone has created a generic routine or program/procedure that processes such a file to generate a new file having one data row for all records including needed variable relabeling?

You can reshape data via stats packages such as: SPSS's casestovars command, or the Reshape package in R.

Here's a link for an SPSS example:

SPSS Scripts contributed by Vivian Haime:

In order to take long data files, from data collected at multiple time points per participants, and reshape them into wide form, I followed these steps:

FROM THE TOOLBAR: Data→Restructure→Restructure selected cases into variables→Identifier_variable(s): Subject ID #; Index_variable(s): REDCap_Event→Yes, data will be sorted by identifier and index variables→group by original variable→FINISH


 SORT CASES BY subject_id redcap_event_name. CASESTOVARS 

You may have to rename the variables afterwards.


More help for SPSS:



Go to KB0027893 in the IS Service Desk

Related articles





Work Instructions