This article describes how to identify and, if required, recover, any cases deleted from a data set.
Working out if there are any deleted cases
You can work out if a file contains deleted cases by clicking on the data set name in the Data Sets tree, and looking at the Number of deleted cases, which is shown on the right. In the example below, three cases have been deleted.
Using the data editor to identify deleted cases
Deleted cases can be identified by viewing the row numbers in the data editor. For example, the screenshot below shows that the 3rd, 4th, and 5th cases have been deleted.
Restoring deleted cases
To restore the deleted cases in a document:
- Select the data set name in the Data Sets tree.
- Press the Restore deleted cases button (in the object inspector).
Using code to identify deleted cases
You can use code to identify deleted cases. This process will end up with all your cases undeleted, but you will have the ability to redelete them (as you will know which cases were deleted). The process is:
- Create a new calculation with code cleaned.ids = ID, where you replace ID with the name of the unique respondent id variable in your data file.
- Turn off Automatic updating for the calculation (see the screenshot below).
- Restore the deleted cases (see the previous section).
- Create a new calculation containing all.ids = ID, where you replace ID with the name of your ID variable.
- Create a calculation containing all.ids[!all.ids %in% cleaned.ids]. The result of this will be the values of the IDs of the deleted cases. Alternatively, if you want to know the case numbers, use which(!all.ids %in% cleaned.ids).
A worked example is shown below.