Faulty filters

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Faulty filters

Alina Sheyman
Hi all,
  Here's a bit of an odd question dealing with filters in SPSS. I have
been running into a problem where I apply a filter to my SPSS database and
then proceed to run some calculations. Despite the fact that the filter
has been set SPSS proceeds to do calculations on all the records, even the
ones that have been filtered out. Any idea why this happens and how I can
get around this problem?
Second part of the question deals with a similar problem. I apply a filter
to pick up only those records where appr_reporting =1 (see below) and then
run the following syntax (each CompanyRecordID here is its own record, so
in reality SPSS is not summarizing anything, but rather simply reporting
on the existing records)-

CTABLES/TABLE CompanyRecordID by Appr_Reporting[MEAN]+Is_Enhanced[MEAN]+
Office_AGE_CAT[MEAN]+Office_AGE_CAT2[MEAN]+q303New[MEAN].

When I run this through SPSS ignores the filter and returns all the
records. Any idea why this is happening?


Alina Sheyman, Family Office Exchange
Reply | Threaded
Open this post in threaded view
|

Re: Faulty filters

Raynald Levesque
Hi

Hi,

1) Re your first question

From spssbase.pdf:

"FILTER is used to exclude cases from program procedures without deleting
them from the active
dataset. When FILTER is in effect, cases with a zero or missing value for
the specified variable
are not used in program procedures."

So, FILTER excludes cases from PROCEDURES but not from TRANSFORMATIONS.
Example:

DATA LIST LIST /id var1.
BEGIN DATA
1 5
2 7
3 8
7 5
10 7
END DATA.

COMPUTE filter$=(id<>2).

* In next block, variable var2 is computed for *all* cases .
* but procedures (here FREQ and CTABLES) excludes cases filtered out.

FILTER BY filter$.
- FREQ VAR=var1.
- COMPUTE var2=var1*10.
- CTABLES
    /VLABELS VARIABLES=var1 id DISPLAY=DEFAULT
    /TABLE id [C] BY var1 [MEAN]
    /CATEGORIES VARIABLES=id ORDER=A KEY=VALUE EMPTY=EXCLUDE
    /TITLES TITLE="id 2 has been filtered out".
FILTER OFF.

* Use DO IF to do transformation only on certain cases .
DO IF filter$=1.
- COMPUTE var3=var1*10.
END IF.
EXE.

2) Re your 2nd question

The example above shows that CTABLES excludes filtered out cases. Please
post the code that ignores filtered out cases (along with sample data).

Cheers!

Raynald Levesque [hidden email]
Visit my SPSS site: http://www.spsstools.net




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Alina Sheyman
Sent: October 2, 2006 5:58 PM
To: [hidden email]
Subject: Faulty filters

Hi all,
  Here's a bit of an odd question dealing with filters in SPSS. I have been
running into a problem where I apply a filter to my SPSS database and then
proceed to run some calculations. Despite the fact that the filter has been
set SPSS proceeds to do calculations on all the records, even the ones that
have been filtered out. Any idea why this happens and how I can get around
this problem?
Second part of the question deals with a similar problem. I apply a filter
to pick up only those records where appr_reporting =1 (see below) and then
run the following syntax (each CompanyRecordID here is its own record, so in
reality SPSS is not summarizing anything, but rather simply reporting on the
existing records)-

CTABLES/TABLE CompanyRecordID by Appr_Reporting[MEAN]+Is_Enhanced[MEAN]+
Office_AGE_CAT[MEAN]+Office_AGE_CAT2[MEAN]+q303New[MEAN].

When I run this through SPSS ignores the filter and returns all the records.
Any idea why this is happening?


Alina Sheyman, Family Office Exchange