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 Sources tree and looking at the Number of deleted cases, which is shown in the Properties . In the example below, three cases have been deleted.
Using the Raw Data to identify deleted cases
Deleted cases can be identified by viewing the row numbers in Raw Data. 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 Sources tree.
- Press the Restore deleted cases button in the Properties
.
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:
- From the toolbar, click Calculation
> Custom Code, and click on the page to place the custom calculation.
-
In the Code
editor, paste
cleaned.ids = ID
where you replace ID with the name of the unique respondent id variable in your data file.
- Turn off Calculate automatically in Properties
for the calculation.
- Restore the deleted cases (see the previous section).
-
Create a new calculation via Calculation
> Custom Code containing:
all.ids = ID
where you replace ID with the name of your ID variable.
-
Create a calculation via Calculation
> Custom Code 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.