|
Hello,
I am new to the list, so I apologize if this questions has been answered before...
I am trying to create a data set with weeks nested within individuals.
In order to do so, I need to duplicate a case with a unique id number a specific number of times (once for each week). I have a variable with a unique identifier and another specifying the number of weeks for that identifier (see 10 case example below). Does anyone know how I might do this, aside from manually of course?
Weeks ID
25 1
4 2 52 3 3 4 25 5 8 6 8 7 11 8 8 9 6 10 Thanks so much,
Ben
Benjamin Steiner, Ph.D.
Assistant Professor
Department of Criminology and Criminal Justice
University of South Carolina
1305 Greene Street
Columbia, SC 29208
803-777-1238
803-777-9600 (fax)
|
|
click <run> <all>. look at the output. Is this what you want? If not please give more detail. data list list /Weeks (f2) ID(f2). begin data 25 1 4 2 52 3 3 4 25 5 8 6 8 7 11 8 8 9 6 10 end data. numeric the_week(f2). loop the_week = 1 to weeks. xsave outfile='d:\project\expand.sav'. end loop. execute. get file='d:\project\expand.sav'. Art Kendall Social Research Consultants STEINER, BENJAMIN wrote:
Art Kendall
Social Research Consultants |
|
In reply to this post by STEINER, BENJAMIN
Benjamin,
This is a way to do this. I'm not sure it is the best or quickest. The basic idea is to use a loop structure to create a many values as you need and then use a varstocases to restructure the dataset. Vector week(60,f2.0). /* key piece: adjust value to needed size. Loop #i=1 to weeks. + compute week(#i)=#i. End loop. Varstocases /make week from week1 to week60/drop weeks. Gene Maguin >>> I am trying to create a data set with weeks nested within individuals. In order to do so, I need to duplicate a case with a unique id number a specific number of times (once for each week). I have a variable with a unique identifier and another specifying the number of weeks for that identifier (see 10 case example below). Does anyone know how I might do this, aside from manually of course? Weeks ID 25 1 4 2 52 3 3 4 25 5 8 6 8 7 11 8 8 9 6 10 Thanks so much, Ben Benjamin Steiner, Ph.D. Assistant Professor Department of Criminology and Criminal Justice University of South Carolina 1305 Greene Street Columbia, SC 29208 803-777-1238 803-777-9600 (fax) [hidden email] ===================== 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 |
| Free forum by Nabble | Edit this page |
