1
votes

I would like to delete some observations from the table in my SPSS, if values meet, for instance:

If product + value from column meet, I want to remove it/make it SYSMIS (only this observation, the observation from another column for this row needs to be still available, so make flag and temporary select is not enough)

Tried several approaches like:

    RECODE VAR2(If(PRODUCT=1 AND VAR2=2000) = SYSMIS)(ELSE=COPY)
EXECUTE.

 IF(PRODUCT=1 AND VAR2=2000) RECODE VAR2(SYSMIS)(ELSE=COPY)
EXECUTE.

None of it works

Is there a way to remove observations in another way than delete it from raw data? I'd like to avoid it

2

2 Answers

2
votes

You might save a lot of work by looking up some basic spss syntax tutorials. See here for a good site.

In the present case all you need is this:

If PRODUCT=1 AND VAR2=2000 VAR2=$SYSMIS.

To make your syntax work with recode, you can do this:

DO IF (PRODUCT=1 AND VAR2=2000).
  RECODE VAR2 (ELSE=SYSMIS).
END IF.
1
votes

It sounds like you might not want to delete the original data, but instead just run your analyses on a subset of data. In that case, use SELECT IF:

SELECT IF (PRODUCT=1 AND VAR2=2000).

Or:

SELECT IF NOT (PRODUCT=1 AND VAR2=2000).

This will delete any row that doesn't fit the condition, and so all subsequent analysis will include only the rows that do.

If you want to be able to filter the rows only temporarily - you can use filter command instead of select.