Glitch in CASESTOVARS? (SPSS 14)

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

Glitch in CASESTOVARS? (SPSS 14)

Richard Ristow
Here, in SPSS 14 (the latest version I have running), CASESTOVARS seems to behave in a way I think wrong, and that seems contrary to the documentation.

The Command Syntax Reference article on CASESTOVARS (p. 195, in the v.14 edition) states (underscores added),

RENAME Subcommand
CASESTOVARS creates variable groups with new variables. The first part of the new variable
name is either derived from the name of the original variable or is the rootname specified on
the
RENAME subcommand.

SEPARATOR Subcommand
CASESTOVARS creates variable groups that contain new variables. There are two parts to the
name of a new variable—a rootname and an index. The parts are separated by a string.
The
separator string is specified on the
SEPARATOR subcommand.
.. If a separator is not specified, the default is a period.

It appears, however, that the root and separator are not used, and the index value alone becomes the variable name, if only one variable is being transposed and (probably) the index variable is a string. That can generate invalid variable names, when using the root and separator would have given valid ones.

Has this persisted in later releases? If so, is it recognized as a bug?

Example (complete data and code are at the end of this posting):
Using the dataset
|-----------------------------|---------------------------|
|Output Created               |09-SEP-2010 00:07:51       |
|-----------------------------|---------------------------|
Group      Inst Name

Primary    1F   Aaron
Primary    1L   Aardvark
Primary    2F   Beth
Primary    2L   Benny
Secondary  1F   Catherine
Secondary  1L   Clark
Secondary  2F   Douglas
Secondary  2L   Draper

Number of cases read:  8    Number of cases listed:  8

and running command
CASESTOVARS
 /ID = Group
 /INDEX = Inst
 /GROUPBY = VARIABLE .

gives messages
Warnings
|---------------------------------------------------------|
|CASES TO VARS created the name "1F" for a new variable.  |
|Its first character is invalid in SPSS, so "v1"          |
|will be used instead.                                    |
|---------------------------------------------------------|
|CASES TO VARS created the name "1L" for a new variable.  |
|Its first character is invalid in SPSS, so "v2"          |
|will be used instead.                                    |
|---------------------------------------------------------|
|CASES TO VARS created the name "2F" for a new variable.  |
|Its first character is invalid in SPSS, so "v3"          |
|will be used instead.                                    |
|---------------------------------------------------------|
|CASES TO VARS created the name "2L" for a new variable.  |
|Its first character is invalid in SPSS, so "v4"          |
|will be used instead.                                    |
|---------------------------------------------------------|

and the result is
|-----------------------------|---------------------------|
|Output Created               |09-SEP-2010 00:07:53       |
|-----------------------------|---------------------------|
Group      v1         v2         v3         v4

Primary    Aaron      Aardvark   Beth       Benny
Secondary  Catherine  Clark      Douglas    Draper

Number of cases read:  2    Number of cases listed:  2

==============================
APPENDIX:  Test data, and code
==============================
*  C:\Documents and Settings\Richard\My Documents  .
*    \Technical\spssx-l\Z-2010abc                  .
*    \2010-09-08 Ristow-Glitch in CASESTOVARS.SPS  .

*  ................................................................. .
*  To support a posting titled "Glitch in CASESTOVARS? (SPSS 14)"    .
*                                                                    .
*  It appears that CASESTOVARS uses only the index value, rather     .
*  than the root, separator and index value, as a variable name,     .
*  when only one variable is being transposed. That can give         .
*  invalid variable names, when using the root and separator would   .
*  give valid ones.                                                  .
*  ................................................................. .

DATA LIST LIST/
    Group     Inst Name
   (A10,      A2,  A10).
BEGIN DATA
    Primary   1F   Aaron
    Primary   1L   Aardvark
    Primary   2F   Beth
    Primary   2L   Benny
    Secondary 1F   Catherine
    Secondary 1L   Clark
    Secondary 2F   Douglas
    Secondary 2L   Draper
END DATA.

LIST.

CASESTOVARS
 /ID = Group
 /INDEX = Inst
 /GROUPBY = VARIABLE .

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
Reply | Threaded
Open this post in threaded view
|

Re: Glitch in CASESTOVARS? (SPSS 14)

Bruce Weaver
Administrator
Hi Richard.  I get the same result with version 18.0.2.  However, if I autorecode Inst to InstNo, and use InstNo as the index, I get this in the restructured file:

 
Group      Inst.1 Inst.2 Inst.3 Inst.4 Name.1     Name.2     Name.3     Name.4
Primary    1F     1L     2F     2L     Aaron      Aardvark   Beth       Benny
Secondary  1F     1L     2F     2L     Catherine  Clark      Douglas    Draper
 
Cheers,
Bruce


Richard Ristow wrote

Here, in SPSS 14 (the latest version I have running), CASESTOVARS seems
to behave in a way I think wrong, and that seems contrary to the
documentation.
The Command Syntax Reference article on
CASESTOVARS (p. 195, in the v.14 edition)
states (underscores added),
RENAME Subcommand
CASESTOVARS
creates variable groups
with new variables. The first part of the new variable
name is either derived from the name of the original variable or is the
rootname specified on
the RENAME
subcommand.
SEPARATOR
Subcommand
CASESTOVARS
creates variable groups
that contain new variables. There are two parts to the
name of a new variable—a rootname and an index. The parts are separated
by a string. The
separator string is specified on the
SEPARATOR
subcommand.
.. If
a separator is not specified, the default is a period.
It appears, however, that the root and separator are not
used, and the index value alone becomes the variable name, if only one
variable is being transposed and (probably) the index variable is a
string. That can generate invalid variable names, when using the root and
separator would have given valid ones.
Has this persisted in later releases? If so, is it recognized as a
bug?

--- snip ---
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Glitch in CASESTOVARS? (SPSS 14)

David Marso
Administrator
In reply to this post by Richard Ristow
Hell, what's wrong with good old fashioned AGGREGATE?
I do all of my data restructuring code OLD SKOOL (both directions)!
That way I know EXACTLY what's happening with my data and I can do insane
crazy shit that's incomprehensible to the mildly retarded data restructuring
wizard.  SPSS hasn't created anything remarkably innovative in that regard
for over a decade.  Have all the creative people left the company?
My AGGREGATE and XSAVE tricks can smoke that stupid wizard l-)

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"