Date: Tue, 9 Jun 2009 10:12:39 +0930
Reply-To: kylie.lange@adelaide.edu.au
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Kylie Lange <kylie.lange@adelaide.edu.au>
Organization: The University of Adelaide
Subject: Re: stacked file restructure
In-Reply-To: <11691.20617.qm@web110716.mail.gq1.yahoo.com>
Content-Type: text/plain; charset="us-ascii"
Thanks Mark and Albert-Jan for your suggestions.
I get an error with the suggested code, possibly because I did not make it
clear enough that the file contains multiple subjects ('ID')? The error
message is:
"The INDEX values for case 2 have occurred before in the cases with the same
ID values. This command is not executed."
Any other suggestions would be appreciated...
Thanks,
Kylie.
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
Albert-jan Roskam
Sent: Friday, 5 June 2009 6:45 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Re: stacked file restructure
Minor addition to the solution below, let it precede with:
compute param = replace(rtrim(param), " ", "_").
--- On Fri, 6/5/09, Mark Webb <targetlk@iafrica.com> wrote:
> From: Mark Webb <targetlk@iafrica.com>
> Subject: Re: stacked file restructure
> To: SPSSX-L@LISTSERV.UGA.EDU
> Date: Friday, June 5, 2009, 11:03 AM
> Try this
>
> SORT CASES BY day param .
> CASESTOVARS
> /ID = day
> /INDEX = param
> /GROUPBY = VARIABLE .
>
>
> Kylie Lange wrote:
> > Hi all,
> >
> > I am hoping for assistance with an awkward data file
> restructure. The
> > original data has been provided in the following
> format (which I have dubbed
> > "stacked"):
> >
> > ID DAY PARAM VALUE
> > 1 0
> WEIGHT 105.6
> > 1 0 SYS
> BP 110
> > 1 0 TEMP
> 34.4
> > 1 7
> WEIGHT 105.1
> > 1 7 SYS
> BP 114
> > 1 7 TEMP
> 33.9
> > ...
> >
> > Ie, each measurement parameter has been listed as a
> separate row in the same
> > variable, rather than getting its own variable (ie,
> the parameters are
> > "stacked" on top of each other).
> >
> > I need to get this data into both of the standard
> formats:
> > - "long" - one row per subject per day with separate
> variables per
> > parameter, and
> > - "wide" - one row per subject with separate variables
> per parameter per day
> > (Obviously, once I can get it into either of the above
> then the other is
> > trivial)
> >
> > That is:
> >
> > ID DAY WEIGHT SYSBP
> TEMP
> > 1 0
> 105.6
> 110 34.4
> > 1 7
> 105.1
> 114 33.9
> > ...
> >
> > ID WEIGHT_0 SYSBP_0 TEMP_0 WEIGHT_7
> SYSBP_7 TEMP_7
> > 1 105.6 110
> 34.4 105.1
> 114 33.9
> > ...
> >
> > A straight CASETOVARS restructure creates all the
> columns needed for the
> > "wide" file above, however with 21 measurement days
> and up to 8 parameters
> > measured each day, there are a total of 124
> day-by-parameter variables
> > created in the restructure and it's a big mess trying
> to name and label each
> > one with the correct day-by-parameter combination
> without making a mistake
> > (and I have over a dozen of these files to do in the
> same way).
> >
> > Is there any way to do this "wide" restructure in such
> a way that the
> > variable naming uses the PARAM entries in the original
> file? Or
> > alternatively, to go straight to the "long" format?
> Any suggestions would be
> > appreciated.
> >
> > Thanks,
> > Kylie.
> >
> > =====================
> > To manage your subscription to SPSSX-L, send a message
> to
> > LISTSERV@LISTSERV.UGA.EDU
> (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
> >
> >
>
> --
> Mark Webb
>
> +27 21 786 4379
> +27 72 199 1000
> Skype - webbmark
> targetlink@iafrica.com
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@LISTSERV.UGA.EDU
> (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
LISTSERV@LISTSERV.UGA.EDU (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
LISTSERV@LISTSERV.UGA.EDU (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
|