VARSTOCASES not seeing the results of COMPUTEs

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

VARSTOCASES not seeing the results of COMPUTEs

Richard Ristow
Adapted from a posting I made recently(1):

In an admittedly elderly SPSS (version 14 for Windows), the code

DATASET ACTIVATE TestData WINDOW=FRONT.
DATASET COPY     Unroll.
DATASET ACTIVATE Unroll   WINDOW=FRONT.

compute suma1=MEAN(maxDiff1alt1,maxDiff2alt1,maxDiff3alt1).
compute suma2=MEAN(maxDiff1alt2,maxDiff2alt2,maxDiff3alt2).
compute suma3=MEAN(maxDiff1alt3,maxDiff2alt3,maxDiff3alt3).

EXECUTE /* appears to be needed for VARSTOCASES to work */.

VARSTOCASES
   /MAKE    Score FROM suma1 TO suma3
   /INDEX = MsgName(Score)
   /KEEP  = CASEID
   /NULL  = DROP.

works as intended; but if the EXECUTE is dropped, i.e.

DATASET ACTIVATE TestData WINDOW=FRONT.
DATASET COPY     Unroll2.
DATASET ACTIVATE Unroll2   WINDOW=FRONT.

compute suma1=MEAN(maxDiff1alt1,maxDiff2alt1,maxDiff3alt1).
compute suma2=MEAN(maxDiff1alt2,maxDiff2alt2,maxDiff3alt2).
compute suma3=MEAN(maxDiff1alt3,maxDiff2alt3,maxDiff3alt3).

VARSTOCASES
   /MAKE    Score FROM suma1 TO suma3
   /INDEX = MsgName(Score)
   /KEEP  = CASEID
   /NULL  = KEEP.

variable "Score" is system-missing in all cases -- if NULL=DROP is
specified, there are no cases at all.

Is this a recognized phenomenon -- that VARSTOCASES doesn't see the
results of transformations unless a data pass is forced first?  Has
it perhaps been recognized as a bug, and fixed, in later releases?
=========================================
(1) See
Date:     Fri, 24 Apr 2015 01:37:45 -0400
From:     Richard Ristow <[hidden email]>
Subject:  Re: Rank messages
Comments: To: mils <[hidden email]>
To:       [hidden email]

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: VARSTOCASES not seeing the results of COMPUTEs

Rick Oliver-3
Well, a very simple example of VARSTOCASES suggests that it handles pending transformations correctly:

dataset close all.
new file.
data list list /x y.
begin data
1 2
3 4
5 6
end data.
dataset name one.
dataset copy two.
dataset activate two.
compute fred=x*2.
varstocases /make newvar from x y fred.


Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        Richard Ristow <[hidden email]>
To:        [hidden email]
Date:        04/24/2015 03:11 PM
Subject:        VARSTOCASES not seeing the results of COMPUTEs
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Adapted from a posting I made recently(1):

In an admittedly elderly SPSS (version 14 for Windows), the code

DATASET ACTIVATE TestData WINDOW=FRONT.
DATASET COPY     Unroll.
DATASET ACTIVATE Unroll   WINDOW=FRONT.

compute suma1=MEAN(maxDiff1alt1,maxDiff2alt1,maxDiff3alt1).
compute suma2=MEAN(maxDiff1alt2,maxDiff2alt2,maxDiff3alt2).
compute suma3=MEAN(maxDiff1alt3,maxDiff2alt3,maxDiff3alt3).

EXECUTE /* appears to be needed for VARSTOCASES to work */.

VARSTOCASES
  /MAKE    Score FROM suma1 TO suma3
  /INDEX = MsgName(Score)
  /KEEP  = CASEID
  /NULL  = DROP.

works as intended; but if the EXECUTE is dropped, i.e.

DATASET ACTIVATE TestData WINDOW=FRONT.
DATASET COPY     Unroll2.
DATASET ACTIVATE Unroll2   WINDOW=FRONT.

compute suma1=MEAN(maxDiff1alt1,maxDiff2alt1,maxDiff3alt1).
compute suma2=MEAN(maxDiff1alt2,maxDiff2alt2,maxDiff3alt2).
compute suma3=MEAN(maxDiff1alt3,maxDiff2alt3,maxDiff3alt3).

VARSTOCASES
  /MAKE    Score FROM suma1 TO suma3
  /INDEX = MsgName(Score)
  /KEEP  = CASEID
  /NULL  = KEEP.

variable "Score" is system-missing in all cases -- if NULL=DROP is
specified, there are no cases at all.

Is this a recognized phenomenon -- that VARSTOCASES doesn't see the
results of transformations unless a data pass is forced first?  Has
it perhaps been recognized as a bug, and fixed, in later releases?
=========================================
(1) See
Date:     Fri, 24 Apr 2015 01:37:45 -0400
From:     Richard Ristow <[hidden email]>
Subject:  Re: Rank messages
Comments: To: mils <[hidden email]>
To:       [hidden email]

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: VARSTOCASES not seeing the results of COMPUTEs

Richard Ristow
At 04:24 PM 4/24/2015, Rick Oliver wrote:

>Well, a very simple example of VARSTOCASES suggests that it handles
>pending transformations correctly.

I ran your code, slightly revised(*), and it didn't pick up the
values of 'fred' -- see below.  So the problem seems to be real, but
version-dependent.  It's not surprising; datasets were new in SPSS
14, and their behavior was sometimes quirky.

(*) Adding an alphanumeric ID field to the records, and formats to
the "data list"; specifying "/NULL=KEEP" on "varstocases"; adding "LIST".

dataset close all.
new file.
data list list / ID x y (A2 2F3).
begin data
A  1 2
B  3 4
C  5 6
end data.
dataset name one.
dataset copy two.
dataset activate two.
compute fred=x*2.
varstocases /make newvar from x y fred/NULL=KEEP.

Variables to Cases
|----------------------------|----------------------------|
|Output Created              |24-APR-2015  18:27:08       |
|----------------------------|----------------------------|
  [two]

Generated Variables
|------|------|
|Name  |Label |
|------|------|
|newvar|<none>|
|------|------|

Processing Statistics
|-------------|-|
|Variables In |4|
|-------------|-|
|Variables Out|2|
|-------------|-|

LIST.
List
|-----------------------------|---------------------------|
|Output Created               |24-APR-2015 18:27:08       |
|-----------------------------|---------------------------|
  [two]
ID newvar

A      1
A      2
A      .
B      3
B      4
B      .
C      5
C      6
C      .

Number of cases read:  9    Number of cases listed:  9
==============================
APPENDIX: Code, exactly as run
==============================
dataset close all.
new file.
data list list / ID x y (A2 2F3).
begin data
A  1 2
B  3 4
C  5 6
end data.
dataset name one.
dataset copy two.
dataset activate two.
compute fred=x*2.
varstocases /make newvar from x y fred/NULL=KEEP.
LIST.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD