Using a filter variable

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Using a filter variable

Bob Schacht-3
I'm having trouble using a filter variable with ver. 12.
First, I execute the following code:
SORT CASES BY SSN(A) DATEAPPL(A) .
MATCH FILES /FILE = * /BY SSN /FIRST = PrimaryFirst /LAST = PrimaryLast2.
DO IF (PrimaryFirst).
COMPUTE MatchSequence = 1 - PrimaryLast2.
ELSE.
COMPUTE MatchSequence = MatchSequence + 1.
END IF.
LEAVE MatchSequence.
FORMAT MatchSequence (f7).
COMPUTE InDupGrp = MatchSequence > 0.
SORT CASES InDupGrp(D).
MATCH FILES /FILE = * /DROP = PrimaryLast2 InDupGrp MatchSequence.
VARIABLE LABELS PrimaryFirst 'Indicator of each first matching case as
Primary' .
VALUE LABELS PrimaryFirst 0 'Duplicate Case' 1 'Primary Case'.
VARIABLE LEVEL PrimaryFirst (ORDINAL).
FREQUENCIES VARIABLES = PrimaryFirst .

Now what I want to do is do a crosstab of PrimaryFirst with another
variable, STAT.
However for some reason PrimaryFirst does not show up on my list of
variables in the drop-down menus, even though it appears in the DataView. I
tried "saving" the database, but after the save it still didn't appear on
the drop down menu list of variables.

Using the menu system, the best I could do was to use Data/Select
Cases/Select If,
and then writing "PrimaryFirst = 0" in the expression window. Note that I
could not select PrimaryFirst from the list of variables on the left
because it does not appear on that list. I had to enter it manually,
resulting in the following syntax:

COMPUTE filter_$=(PrimaryFirst = 0).
VARIABLE LABEL filter_$ 'PrimaryFirst = 0 (FILTER)'.
VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

Now, having used the filtered filter to select the cases I wanted, I could
then finish off the desired crosstab with
FREQUENCIES  VARIABLES=STAT CLOSCODE  /ORDER=  ANALYSIS .

Why was my new filter variable, PrimaryFirst, hidden in the menu list of
variables?

Bob Schacht

Robert M. Schacht, Ph.D. <[hidden email]>
Pacific Basin Rehabilitation Research & Training Center
1268 Young Street, Suite #204
Research Center, University of Hawaii
Honolulu, HI 96814