CASETOVARS - order of generated variables?

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

CASETOVARS - order of generated variables?

Bailer Harald-2
Dear listers,

I'm still working with SPSS V11.0.1.

I have questionnaire data in long data set. Respondents (name) answered 38 items (i01 to i38) once, twice, three or four times. For each time the date (messdat) is registered. So there are up to four entries per respondent (in most cases 2 times).
Thus, file structure:
name (A50) messdat (EDATE10) i01 to i39 (F11.0);
nearly 3000 rows related to 1600 respondents.

Since repeated measures should be analysed I need to transform the long set to a wide one with only one respondent per row.
I created an index-variable (mpzneu) based on the date of the measurement to identify the first, second etc. time of measurement:

SORT CASES BY
  name (A) messdat (A) .
numeric mzpneu (f1.0).
compute mzpneu = 1.
if (lag(name,1) = name) mzpneu = lag(mzpneu,1) + 1.
freq mzpneu.

Next step should be CASETOVARS:

CASESTOVARS
 /ID = name
 /rename messdat = mdat
 /index = mzpneu
 /COUNT = n .

The ID grants me one row per name.
Rename gives me the names mdat.1 ... 4 for the measure points (messdat.x is too long).
Index should give an index to messdat and i01... i38 for the measure points.
Count allows checking how much rows were collapsed for one case.

For the resulting data set I would have expected the variables to be in original order and look like:
name n mdat.1 mdat.2... i01.1 i01.2 i01.3 ... i38.2 i38.3 i38.4 ,
although, I would prefer to have the items to be grouped consecutively for each measure point, (i.e. i01.1 i02.1 ... i38.1 i01.2 ... i38.2 ... i37.4 i38.4.)

For each item the four generated ones representing the four measures are in expected order,
e.g. i01.1 i01.2 i01.3 i01.4.

But the generated sequence of items is in an order I don't understand:
i01 to i08, i12, i14, i17 to i21, i23 to i26, i29, i33, i34, i37, i09 to i11, i13, i15, i22, i27, i28, i31, i38, i16, i30, i36, i32, i35.

If I delete i11 to i38 and do CASETOVARS the sequence of i01 to i10 is correct, the same for keeping i01 to i11.
Disorder shows up with i01 to i12 and i13 resp.: i12 is placed between i08 and i09.
The hypothesis that the disorder arises for more than 11 variables must be rejected: CASETOVARS with i01 to i05 i35 to i38 gives the order i01 to i05, i37, i38, i36, i35.

I checked some other (not all) variations. It seems to be that the (dis)order for all 38 items remains stable, i.e. the generated variables from each subsample of the 38 items would follow this order.

Any ideas what may be a cause? Am I missing some essential points?

If I have to live with this mix-up what would be a good way to rearrange the items?

Thank you for sharing your thoughts

Harald

=====================
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: CASETOVARS - order of generated variables?

Bruce Weaver
Administrator
"Since repeated measures should be analysed I need to transform the long set to a wide one with only one respondent per row."

I assume you mean repeated measures ANOVA.  If so, an alternative you might consider is leaving the data file the way it is and using MIXED to do the analysis.  There is an example in the Command Syntax Reference manual (aka the FM).  

HTH.


Bailer Harald-2 wrote
Dear listers,

I'm still working with SPSS V11.0.1.

I have questionnaire data in long data set. Respondents (name) answered 38 items (i01 to i38) once, twice, three or four times. For each time the date (messdat) is registered. So there are up to four entries per respondent (in most cases 2 times).
Thus, file structure:
name (A50) messdat (EDATE10) i01 to i39 (F11.0);
nearly 3000 rows related to 1600 respondents.

Since repeated measures should be analysed I need to transform the long set to a wide one with only one respondent per row.
I created an index-variable (mpzneu) based on the date of the measurement to identify the first, second etc. time of measurement:

SORT CASES BY
  name (A) messdat (A) .
numeric mzpneu (f1.0).
compute mzpneu = 1.
if (lag(name,1) = name) mzpneu = lag(mzpneu,1) + 1.
freq mzpneu.

Next step should be CASETOVARS:

CASESTOVARS
 /ID = name
 /rename messdat = mdat
 /index = mzpneu
 /COUNT = n .

The ID grants me one row per name.
Rename gives me the names mdat.1 ... 4 for the measure points (messdat.x is too long).
Index should give an index to messdat and i01... i38 for the measure points.
Count allows checking how much rows were collapsed for one case.

For the resulting data set I would have expected the variables to be in original order and look like:
name n mdat.1 mdat.2... i01.1 i01.2 i01.3 ... i38.2 i38.3 i38.4 ,
although, I would prefer to have the items to be grouped consecutively for each measure point, (i.e. i01.1 i02.1 ... i38.1 i01.2 ... i38.2 ... i37.4 i38.4.)

For each item the four generated ones representing the four measures are in expected order,
e.g. i01.1 i01.2 i01.3 i01.4.

But the generated sequence of items is in an order I don't understand:
i01 to i08, i12, i14, i17 to i21, i23 to i26, i29, i33, i34, i37, i09 to i11, i13, i15, i22, i27, i28, i31, i38, i16, i30, i36, i32, i35.

If I delete i11 to i38 and do CASETOVARS the sequence of i01 to i10 is correct, the same for keeping i01 to i11.
Disorder shows up with i01 to i12 and i13 resp.: i12 is placed between i08 and i09.
The hypothesis that the disorder arises for more than 11 variables must be rejected: CASETOVARS with i01 to i05 i35 to i38 gives the order i01 to i05, i37, i38, i36, i35.

I checked some other (not all) variations. It seems to be that the (dis)order for all 38 items remains stable, i.e. the generated variables from each subsample of the 38 items would follow this order.

Any ideas what may be a cause? Am I missing some essential points?

If I have to live with this mix-up what would be a good way to rearrange the items?

Thank you for sharing your thoughts

Harald

=====================
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
--
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: CASETOVARS - order of generated variables?

PRogman
In reply to this post by Bailer Harald-2
I'm not sure about SPSS v11 implementation, but I'd read TFM on
CASETOVARS
 /GROUPBY command.

or use

MATCH FILES
  FILE=*
 /KEEP=  {varlist} .          i.e i01.1 i02.1 ... i38.1 i01.2 ... i38.2 ... i37.4 i38.4 .
EXECUTE.