|
I have never aggregated data before and I am confused about how to make it work for my data set. Here is my problem... I have a data set with stacked data and i need to change it so that there is a single case per person in order to be able to run my analysis on it. I have people who were measured on their level of depression at different times throughout therapy. The problem is that the participants were not measured at equal intervals. Here is a simplified example of what my data looks like
ID Session# Depression 1 0 4 1 10 3 1 50 1 2 1 5 2 7 4 2 40 2 3 0 4 3 12 3 3 40 2 3 60 0 Can anyone tell me how I would use the aggregate command to change data similar to this into a single case per person. Thanks. Kristen |
|
Can you say a little more about the kind of analysis you plan to do?
What you're describing is probably the casestovars function - not aggregate. But, it's likely that you do not need to restructure the file at all. If nothing else, an example of what you'd like this sample file to ultimately look like be would be useful. -Gary On 7/27/07, Kristen M <[hidden email]> wrote: > I have never aggregated data before and I am confused about how to make it > work for my data set. Here is my problem... I have a data set with stacked > data and i need to change it so that there is a single case per person in > order to be able to run my analysis on it. I have people who were measured > on their level of depression at different times throughout therapy. The > problem is that the participants were not measured at equal intervals. Here > is a simplified example of what my data looks like > > ID Session# Depression > 1 0 4 > 1 10 3 > 1 50 1 > 2 1 5 > 2 7 4 > 2 40 2 > 3 0 4 > 3 12 3 > 3 40 2 > 3 60 0 > > Can anyone tell me how I would use the aggregate command to change data > similar to this into a single case per person. Thanks. > Kristen > -- > View this message in context: http://www.nabble.com/aggregating-data-tf4160872.html#a11838867 > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > |
|
Specifically,
new file. data list free /id Session Depression. begin data 1 0 4 1 10 3 1 50 1 2 1 5 2 7 4 2 40 2 3 0 4 3 12 3 3 40 2 3 60 0 end data. * if you want data in aggregate form *. dataset declare AGG. aggregate outfile = AGG /break = id /Total_Sessions = sum(session) /Mean_Depression = mean(Depression). dataset activate AGG. *...yields:. id Total_Sessions Mean_Depression 1.00 60.00 2.67 2.00 48.00 3.67 3.00 112.00 2.25...... * or if you want to preserve the raw data, but restructure it into single cases *. casestovars /id = id. *...yields:. id session.1 session.2 etc............... 1.00 .00 10.00 2.00 1.00 7.00 3.00 .00 12.00............ I hope that helps, -Gary |
| Free forum by Nabble | Edit this page |
