Spss syntax help

Spss syntax help

Post by Oduo » Sat, 19 Jul 2003 00:38:38



I need some assisatance. How do write syntax for checking a set of
values is a complete subset of another by using a flagging variable
chk' where chk=1 is not a subset while 0 is a complete subset
irrespective of the order.

Eg 1.

Data list free/ id x1 to x2 p1 to p2 chk.
Begin data
1 2 3 3 2  0
2 2 1 3 6  1
3 5 6 6 5  0
4 7 8 7 9  1
5 2 5 5 2  0
6 4 5 4 5  0
7 5 8 8 9  1
8 2 9 3 9  1
9 2 5 2 5  0
end data.

Eg 2.
Data list free/ id x1 to x5 p1 to p3 chk.
Begin data
1       3       1       2       5       6       2       5       1       1
2       7       8       9       6       5       7       3       5       0
3       3       6       9       8       5       8       9       6       1
4       3       5       8       7       9       5       7       6       0
5       5       8       9       7       4       5       8       9       1
6       9       7       4       5       8       4       9       2       0
7       6       5       8       9       4       5       8       9       1
8       6       5       9       8       7       7       5       1       0
9       8       7       9       6       5       9       6       5       1
End data.

 
 
 

Spss syntax help

Post by Bruce Weave » Sat, 19 Jul 2003 01:44:25



> I need some assisatance. How do write syntax for checking a set of
> values is a complete subset of another by using a flagging variable
> chk' where chk=1 is not a subset while 0 is a complete subset
> irrespective of the order.

> Eg 1.

> Data list free/ id x1 to x2 p1 to p2 chk.
> Begin data
> 1 2 3 3 2  0
> 2 2 1 3 6  1
> 3 5 6 6 5  0
> 4 7 8 7 9  1
> 5 2 5 5 2  0
> 6 4 5 4 5  0
> 7 5 8 8 9  1
> 8 2 9 3 9  1
> 9 2 5 2 5  0
> end data.

> Eg 2.
> Data list free/ id x1 to x5 p1 to p3 chk.
> Begin data
> 1  3       1       2       5       6       2       5       1       1
> 2  7       8       9       6       5       7       3       5       0
> 3  3       6       9       8       5       8       9       6       1
> 4  3       5       8       7       9       5       7       6       0
> 5  5       8       9       7       4       5       8       9       1
> 6  9       7       4       5       8       4       9       2       0
> 7  6       5       8       9       4       5       8       9       1
> 8  6       5       9       8       7       7       5       1       0
> 9  8       7       9       6       5       9       6       5       1
> End data.

It looks like you've got the coding for CHK reversed in your
two examples.  CHK=1 indicates that P is NOT a subset of X
in Example 1, but vice versa in Example 2.

The following may not be the most elegant method, but I
think it achieves what you're after:

* ----- Example 1 ------- .

Data list free/ id x1 to x2 p1 to p2 (5f2.0).
Begin data
1 2 3 3 2
2 2 1 3 6
3 5 6 6 5
4 7 8 7 9
5 2 5 5 2
6 4 5 4 5
7 5 8 8 9
8 2 9 3 9
9 2 5 2 5
end data.

numeric chk flag1 to flag2 (f1.0).
exe.

vector
  p = p1 to p2 /
  x = x1 to x2 /
  f = flag1 to flag2.
loop a = 1 to 2.
compute f(a) = 0.
loop b = 1 to 2.
-       if (f(a)=0) f(a) = (p(a) = x(b)).
end loop.
end loop.
exe.

compute chk = sum(flag1 to flag2) = 2.
exe.

val lab chk
  1 'P-scores are a subset of X-scores'
  0 'P-scores are NOT a subset of X-scores'.

list id to chk.

* ----- Example 2 ------- .

Data list free/ id x1 to x5 p1 to p3 (9f2.0).
Begin data
1       3       1       2       5       6       2       5       1
2       7       8       9       6       5       7       3       5
3       3       6       9       8       5       8       9       6
4       3       5       8       7       9       5       7       6
5       5       8       9       7       4       5       8       9
6       9       7       4       5       8       4       9       2
7       6       5       8       9       4       5       8       9
8       6       5       9       8       7       7       5       1
9       8       7       9       6       5       9       6       5
End data.

numeric chk flag1 to flag3 (f1.0).
exe.

vector
  p = p1 to p3 /
  x = x1 to x5 /
  f = flag1 to flag3.
loop a = 1 to 3.
compute f(a) = 0.
loop b = 1 to 5.
-       if (f(a)=0) f(a) = (p(a) = x(b)).
end loop.
end loop.
exe.

compute chk = sum(flag1 to flag3) = 3.
exe.

val lab chk
  1 'P-scores are a subset of X-scores'
  0 'P-scores are NOT a subset of X-scores'.

list id to chk.

* --- End of syntax ----.

Cheers,
Bruce
--
Bruce Weaver

www.angelfire.com/wv/bwhomedir/

 
 
 

1. SPSS Syntax Help- need just a bit

Hi,

I'm new to the syntax of SPSS.  I have only ever used the windows based
functions.  However, now I have been given a task with a large database that
requires the use of some syntax.  I am hoping someone can quickly help me.

I have to do two different things.  The data is from a questionnaire.  There
are some ordinal scale questions with Likert scales.  It is those that I
have to work with.

1. Is to combine the scores from 2 questions (both with participants coded
as 0 or 1) to form a new score and variable of disordered = 1 and
non-disordered = 0.  For instance subjects have scored 1 on questions 15 &
13 then they are coded as disordered (1) on the new variable.  If they have
scored 1 on question 15, but 0 on 13, then they will be coded as
non-disordered on the new variable (0).

2. One question is already coded into (0) and (1).  I have to combined those
results with those from an ordinally scaled question from 1 to 5, to
classify participants into disordered and non-disordered.  For instance, if
a participant is coded as (1) on question 13 and score 1, 2 on question 14
then they are coded as disordered (1) on the new variable.  If a participant
is coded as (1) on question 13 and score 4, 5 on question 14 then they are
coded as non-disordered (0) on the new variable.  Those who scored 3 on
question 14 are ignored as they cannot be diagnosed.

Any help would be very much appreciated.

Steve Feelgood.

Berlin

2. Cisco 3810 - Hangs on a "no shutdown" of BRI0

3. Need help for SPSS Syntax about database capture

4. Notice of serious vulnerabilities in ISC BIND 4 & 8

5. Parsing SPSS Syntax

6. I am stuck

7. editors that do syntax highlighting for SPSS

8. HP Flash Disks and IBM Thinkpads

9. Old SPSS/PC+ syntax

10. SPSS 11.5 - Script - Syntax

11. Repost: Translate syntax from SAS to SPSS to analyse data from AB/BA cross-over trial

12. Translate syntax from SAS to SPSS to analyse data from cross-over trial

13. Problem using TextPad as SPSS Syntax Editor