help restructuring a dataset

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

help restructuring a dataset

Buhi, Eric
Banned User
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: help restructuring a dataset

Maguin, Eugene
As others have pointed out (repeatedly), it's extremely useful to post syntax when you are having syntax problems. So, when you say 'restructure', i assume you mean casestovars. But maybe you don't.

So, post your syntax! Furthermore, i think you should also post the code for reading the data.

Gene Maguin


 On Mon 02/13/12  9:17 PM , "Buhi, Eric" [hidden email] sent:

> Hi list mates,
> A colleague and I are having some trouble restructuring a dataset.
> Currently, the data are imported from an ACASI file directly into
> SPSS. Data for each person, which are various assessments (e.g., P1,
> P2, P3), are on individual rows. I would like to "unstuck" the data so
> that each person's assessments are together on a single row (1 row = 1
> case/person). Unfortunately, due to completely missing assessments,
> when I restructure the data, the variables do not line up in the
> appropriate rows. For instance, because the time 4 assessment below is
> missing for Pat, Pat's time 5 assessment lines up with Sam's time 4
> assessment data. Do you know how I can write syntax to fix this issue?
> Stacked dataset
> ID Time other variables
> PatP1010100 00
> PatP201100 101
> PatP301010100
> PatP5010 10101
> SamP10101 000
> SamP201100 10
> SamP3010 1010
> SamP4001 0101
> SamP50101 010
> Restructured dataset
> PatP1010100 00PatP201100 101PatP301010100 PatP5010 10101
> SamP10101 000SamP201100 10SamP3010 1010SamP4001 0101SamP50101 010
> Many thanks in advance!
> -Eric
> Eric R. Buhi, MPH, PhD
>
> Assistant Professor
>
> Department of Community and Family Health
>
> College of Public Health
>
> University of South Florida
>
> 13201 Bruce B. Downs Blvd., MDC 56
>
> Tampa, Florida 33612
>
> Phone: 813-974-5290
> http://health.usf.edu/publichealth/cfh/CRUSH.htm [2]
>
>
> Links:
> ------
> [2] http://health.usf.edu/publichealth/cfh/CRUSH.htm
>
>

=====================
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: help restructuring a dataset

Jon K Peck
In reply to this post by Buhi, Eric
It might be as simple as this.
CASESTOVARS
  /ID=id
  /INDEX=time
/GROUPBY=INDEX.

Using time as the index variables keeps the missing record(s) from causing the subsequent data for an from collapsing into the hole.
HTH,


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        "Buhi, Eric" <[hidden email]>
To:        [hidden email]
Date:        02/13/2012 07:22 PM
Subject:        [SPSSX-L] help restructuring a dataset
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hi list mates,

A colleague and I are having some trouble restructuring a dataset. Currently, the data are imported from an ACASI file directly into SPSS. Data for each person, which are various assessments (e.g., P1, P2, P3), are on individual rows. I would like to “unstuck” the data so that each person's assessments are together on a single row (1 row = 1 case/person). Unfortunately, due to completely missing assessments, when I restructure the data, the variables do not line up in the appropriate rows. For instance, because the time 4 assessment below is missing for Pat, Pat's time 5 assessment lines up with Sam's time 4 assessment data. Do you know how I can write syntax to fix this issue?

Stacked dataset

ID Time other variables
PatP1010100 00
PatP201100 101
PatP301010100
PatP5010 10101
SamP10101 000
SamP201100 10
SamP3010 1010
SamP4001 0101
SamP50101 010

Restructured dataset

PatP1010100 00PatP201100 101PatP301010100 PatP5010 10101
SamP10101 000SamP201100 10SamP3010 1010SamP4001 0101SamP50101 010

Many thanks in advance!

-Eric

 
Eric R. Buhi, MPH, PhD
Assistant Professor
Department of Community and Family Health
College of Public Health
University of South Florida
13201 Bruce B. Downs Blvd., MDC 56
Tampa, Florida 33612
Phone: 813-974-5290
ebuhi@...
http://health.usf.edu/publichealth/cfh/CRUSH.htm
 
 
Reply | Threaded
Open this post in threaded view
|

Re: help restructuring a dataset

David Marso
Administrator
In reply to this post by Buhi, Eric
See the Syntax reference guide:
VECTOR particularly the example VECTOR outside a LOOP.
HTH, David
Buhi, Eric wrote
Hi list mates,

A colleague and I are having some trouble restructuring a dataset. Currently, the data are imported from an ACASI file directly into SPSS. Data for each person, which are various assessments (e.g., P1, P2, P3), are on individual rows. I would like to "unstuck" the data so that each person's assessments are together on a single row (1 row = 1 case/person). Unfortunately, due to completely missing assessments, when I restructure the data, the variables do not line up in the appropriate rows. For instance, because the time 4 assessment below is missing for Pat, Pat's time 5 assessment lines up with Sam's time 4 assessment data. Do you know how I can write syntax to fix this issue?

Stacked dataset
ID Time other variables
PatP1010100 00
PatP201100 101
PatP301010100
PatP5010 10101
SamP10101 000
SamP201100 10
SamP3010 1010
SamP4001 0101
SamP50101 010

Restructured dataset
PatP1010100 00PatP201100 101PatP301010100 PatP5010 10101
SamP10101 000SamP201100 10SamP3010 1010SamP4001 0101SamP50101 010

Many thanks in advance!

-Eric

Eric R. Buhi, MPH, PhD
Assistant Professor
Department of Community and Family Health
College of Public Health
University of South Florida
13201 Bruce B. Downs Blvd., MDC 56
Tampa, Florida 33612
Phone: 813-974-5290
[hidden email]<mailto:[hidden email]>
http://health.usf.edu/publichealth/cfh/CRUSH.htm
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?"