Desktop User Guides > Professional > Data management scripting > Data Management Script (DMS) file > Filtering data in a DMS file > Cleaning data in an ongoing study
 
Cleaning data in an ongoing study
When cleaning data in an ongoing study, you might want to set up a case data filter to include only cases that have not been cleaned before. One way of doing this is to use a global SQL variable: see GlobalSQLVariables section. In the cleaning script, you can also specify that some cases are to be excluded; for example, because they contain questionable responses. In the DMS file, define this type of case data filter by using the dmgrJob.DropCurrentCase method in the OnNextCase Event section. Here is an example:
Event(OnNextCase)
If age < 0 Then dmgrJob.DropCurrentCase()
.
.
.
End Event
You can also use an update query in the OutputDataSource section to remove case data records from the output data source. For example, the following snippet shows how you could use update queries in two OutputDataSource sections to split the case data between two output data sources--one of which stores the clean data and the other the dirty data.
OutputDataSource(Clean, "My clean data")
ConnectionString = "Provider=mrOleDB.Provider.2; _
Data Source=mrDataFileDsc; _
Location=C:\Program
Files\IBM\SPSS\DataCollection\7\DDL\Output\CleanData.ddf"
MetaDataOutputName = "C:\Program
Files\IBM\SPSS\DataCollection\7\DDL\Output\CleanData.mdd"
UpdateQuery="DELETE FROM vdata _
WHERE DataCleaning.Status = {NeedsReview}"
End OutputDataSource

OutputDataSource(Dirty, "My dirty data")
ConnectionString = "Provider=mrOleDB.Provider.2; _
Data Source=mrDataFileDsc; _
Location=C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\DirtyData.ddf"
MetaDataOutputName = "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\DirtyData.mdd"
UpdateQuery="DELETE FROM vdata _
WHERE NOT DataCleaning.Status.ContainsAny({NeedsReview})"
End OutputDataSource
This example is in the SplitIntoDirtyAndClean.dms sample. See Sample DMS files.
See also
Case data filter
Filtering data in a DMS file
Data Management Script (DMS) file