close Method (Python)

.close(). Closes the dataset. This method closes a dataset accessed through or created by the Dataset class. It cannot be used to close an arbitrary open dataset. When used, it must be called prior to EndDataStep or EndProcedure.

  • If the associated dataset is not the active dataset, that dataset is closed and no longer available in the session. The associated dataset will, however, remain open outside of the data step or procedure in which it was created if the close method is not called.
  • If the associated dataset is the active dataset, the association with the dataset's name is broken. The active dataset remains active but has no name.

Note: Datasets that are not required outside of the data step or procedure in which they were accessed or created should be closed prior to ending the data step or procedure in order to free the resources allocated to the dataset.

Example

import spss
spss.StartDataStep()
datasetObj1 = spss.Dataset()
datasetObj2 = datasetObj1.deepCopy(name="copy1")
datasetObj1.close()
spss.EndDataStep()