|
Dear all,
I've a dataset like this: DATA LIST FREE/ID Var. BEGIN DATA 1 1 1 2 1 3 2 4 2 5 2 6 3 7 3 8 3 9 END DATA. I'd like to restructure it to this: data list free/var1 var2 var3. begin data. 1 4 7 2 5 8 3 6 9 end data. I think it should be possible with CASESTOVARS: casestovars /ID=ID /index=Var. However, this doesn't yield the desired result. I apologize for my clumsiness with casestovars but could anybody please show how it should be done? TIA! Ruben van den Berg What can you do with the new Windows Live? Find out |
|
Dear Ruben,
I think it should be:
DATA
LIST FREE/ID Var.
BEGIN DATA 1 1 2 2 3 3 1 4 2 5 3 6 1 7 2 8 3 9 END DATA. The way
you did it, case 1 probably got values of 1, 2, and 3, case 2 got values of 4,5,
and 5, and so on. Goodluck!
Joost
van Ginkel
Joost R. Van Ginkel, PhD
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben van den Berg Sent: 08 September 2009 11:25 To: [hidden email] Subject: Data file restructure I've a dataset like this: DATA LIST FREE/ID Var. BEGIN DATA 1 1 1 2 1 3 2 4 2 5 2 6 3 7 3 8 3 9 END DATA. I'd like to restructure it to this: data list free/var1 var2 var3. begin data. 1 4 7 2 5 8 3 6 9 end data. I think it should be possible with CASESTOVARS: casestovars /ID=ID /index=Var. However, this doesn't yield the desired result. I apologize for my clumsiness with casestovars but could anybody please show how it should be done? TIA! Ruben van den Berg What can you do with the new Windows Live? Find out ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. **********************************************************************
|
|
In reply to this post by Ruben Geert van den Berg
Hi Ruben, try this:
DATA LIST FREE/ID Var. BEGIN DATA 1 1 1 2 1 3 2 4 2 5 2 6 3 7 3 8 3 9 END DATA.
compute aux = 1. form aux (f2) . if ($casenum > 1 and ID = lag(ID) ) aux = lag(aux ) + 1 . exe. SORT CASES BY AUX ID. CASESTOVARS /ID = aux /INDEX = ID /GROUPBY = VARIABLE .
Jan From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben van den Berg Sent: Tuesday, September 08, 2009 11:25 AM To: [hidden email] Subject: Data file restructure I've a dataset like this: DATA LIST FREE/ID Var. BEGIN DATA 1 1 1 2 1 3 2 4 2 5 2 6 3 7 3 8 3 9 END DATA. I'd like to restructure it to this: data list free/var1 var2 var3. begin data. 1 4 7 2 5 8 3 6 9 end data. I think it should be possible with CASESTOVARS: casestovars /ID=ID /index=Var. However, this doesn't yield the desired result. I apologize for my clumsiness with casestovars but could anybody please show how it should be done? TIA! Ruben van den Berg What can you do with the new Windows Live? Find out _____________ Tato zpráva
a všechny připojené
soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste
oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo
jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně,
prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel
nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto
přenosem.
P Are you sure that you
really need a print version of this message and/or its attachments? Think about
nature.
|
|
Thanks very much, that is exactly what I was looking for!
Ruben Date: Tue, 8 Sep 2009 11:39:09 +0200 From: [hidden email] Subject: Re: Data file restructure To: [hidden email] Hi Ruben, try this:
DATA LIST FREE/ID Var. BEGIN DATA 1 1 1 2 1 3 2 4 2 5 2 6 3 7 3 8 3 9 END DATA. compute aux = 1. form aux (f2) . if ($casenum > 1 and ID = lag(ID) ) aux = lag(aux ) + 1 . exe. SORT CASES BY AUX ID. CASESTOVARS /ID = aux /INDEX = ID /GROUPBY = VARIABLE . Jan From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben van den Berg Sent: Tuesday, September 08, 2009 11:25 AM To: [hidden email] Subject: Data file restructure I've a dataset like this: DATA LIST FREE/ID Var. BEGIN DATA 1 1 1 2 1 3 2 4 2 5 2 6 3 7 3 8 3 9 END DATA. I'd like to restructure it to this: data list free/var1 var2 var3. begin data. 1 4 7 2 5 8 3 6 9 end data. I think it should be possible with CASESTOVARS: casestovars /ID=ID /index=Var. However, this doesn't yield the desired result. I apologize for my clumsiness with casestovars but could anybody please show how it should be done? TIA! Ruben van den Berg What can you do with the new Windows Live? Find out _____________ Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.
P Are you sure that you really need a print version of this message and/or its attachments? Think about nature. -.- --See all the ways you can stay connected to friends and family |
|
In reply to this post by Spousta Jan
|
|
Administrator
|
For any computation, if one of the elements is missing, the result will also be missing. So the only way around this, I think, is to impute some date wherever a date is missing. Whether it is possible (and reasonable) to do so is something your colleague will have to judge.
--
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/). |
|
| Free forum by Nabble | Edit this page |
