Hi Listserv:
The newsgroup told me you were the guy to ask this question, so far I haven't been able to solve it, neither my newsgroup... I have a SPSS table that looks like this. ID Q1 Q2 Q3 ================== 1 4 7 8 1 7 10 12 1 8 14 18 2 11 22 33 2 18 21 9 2 7 7 9 And I would like to display it like this. ID Q1.1 Q2.1 Q3.1 Q1.2 Q2.2 Q3.2 Q1.3 Q2.3 Q3.3 ==================================================== 1 4 7 8 7 10 12 8 14 18 2 11 22 33 18 21 9 7 7 9 I always have "3 lines per case" with the respective ID, and would like to have a "one line per case" with variable labels that correspond. Thanks for your time. Regards, Eugenio Grant |
Hi Eugenio,
The syntax below does what you want. SORT CASES BY Id . CASESTOVARS /ID = Id /GROUPBY = VARIABLE . Thanks . Edward. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Eugenio Grant Sent: Tuesday, November 21, 2006 10:24 AM To: [hidden email] Subject: Rearranging Data... Importance: High Hi Listserv: The newsgroup told me you were the guy to ask this question, so far I haven't been able to solve it, neither my newsgroup... I have a SPSS table that looks like this. ID Q1 Q2 Q3 ================== 1 4 7 8 1 7 10 12 1 8 14 18 2 11 22 33 2 18 21 9 2 7 7 9 And I would like to display it like this. ID Q1.1 Q2.1 Q3.1 Q1.2 Q2.2 Q3.2 Q1.3 Q2.3 Q3.3 ==================================================== 1 4 7 8 7 10 12 8 14 18 2 11 22 33 18 21 9 7 7 9 I always have "3 lines per case" with the respective ID, and would like to have a "one line per case" with variable labels that correspond. Thanks for your time. Regards, Eugenio Grant |
In reply to this post by Eugenio Grant
Hi Eugenio,
You wrote : EG>I received a message that says "casestovars" is not a valid command. I have EG>SPSS 8, could this be the problem? EG>Is there a different name for the command on SPSS 8. I am using SPSS V 14.0 . I dont think SPSS 8 has the "casestovars" command (I stand to be corrected). My be somebody on this will be able to advice on how you could do that in SPSS 8.0 . Thanks. Edward. -----Original Message----- From: Eugenio Grant [mailto:[hidden email]] Sent: Tuesday, November 21, 2006 11:14 AM To: Edward Boadi Subject: RE: Rearranging Data... Hi: I received a message that says "casestovars" is not a valid command. I have SPSS 8, could this be the problem? Is there a different name for the command on SPSS 8. Thanks for your time!!! ______________________________ Eugenio Grant Mora Investigación de Medios Ipsos Costa Rica Tel 257-0304 -----Mensaje original----- De: Edward Boadi [mailto:[hidden email]] Enviado el: Martes, 21 de Noviembre de 2006 09:55 a.m. Para: Eugenio Grant; [hidden email] Asunto: RE: Rearranging Data... Hi Eugenio, The syntax below does what you want. SORT CASES BY Id . CASESTOVARS /ID = Id /GROUPBY = VARIABLE . Thanks . Edward. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Eugenio Grant Sent: Tuesday, November 21, 2006 10:24 AM To: [hidden email] Subject: Rearranging Data... Importance: High Hi Listserv: The newsgroup told me you were the guy to ask this question, so far I haven't been able to solve it, neither my newsgroup... I have a SPSS table that looks like this. ID Q1 Q2 Q3 ================== 1 4 7 8 1 7 10 12 1 8 14 18 2 11 22 33 2 18 21 9 2 7 7 9 And I would like to display it like this. ID Q1.1 Q2.1 Q3.1 Q1.2 Q2.2 Q3.2 Q1.3 Q2.3 Q3.3 ==================================================== 1 4 7 8 7 10 12 8 14 18 2 11 22 33 18 21 9 7 7 9 I always have "3 lines per case" with the respective ID, and would like to have a "one line per case" with variable labels that correspond. Thanks for your time. Regards, Eugenio Grant |
In reply to this post by Eugenio Grant
Hi All,
Raynald has some old examples on his SPSS pages: http://www.spsstools.net/SampleSyntax.htm#RestructureFile Even better is to purchase a new version of SPSS, of course ;-) Greetings Jan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Edward Boadi Sent: Tuesday, November 21, 2006 5:21 PM To: [hidden email] Subject: Re: Rearranging Data... Hi Eugenio, You wrote : EG>I received a message that says "casestovars" is not a valid command. EG>I have SPSS 8, could this be the problem? EG>Is there a different name for the command on SPSS 8. I am using SPSS V 14.0 . I dont think SPSS 8 has the "casestovars" command (I stand to be corrected). My be somebody on this will be able to advice on how you could do that in SPSS 8.0 . Thanks. Edward. -----Original Message----- From: Eugenio Grant [mailto:[hidden email]] Sent: Tuesday, November 21, 2006 11:14 AM To: Edward Boadi Subject: RE: Rearranging Data... Hi: I received a message that says "casestovars" is not a valid command. I have SPSS 8, could this be the problem? Is there a different name for the command on SPSS 8. Thanks for your time!!! ______________________________ Eugenio Grant Mora Investigación de Medios Ipsos Costa Rica Tel 257-0304 -----Mensaje original----- De: Edward Boadi [mailto:[hidden email]] Enviado el: Martes, 21 de Noviembre de 2006 09:55 a.m. Para: Eugenio Grant; [hidden email] Asunto: RE: Rearranging Data... Hi Eugenio, The syntax below does what you want. SORT CASES BY Id . CASESTOVARS /ID = Id /GROUPBY = VARIABLE . Thanks . Edward. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Eugenio Grant Sent: Tuesday, November 21, 2006 10:24 AM To: [hidden email] Subject: Rearranging Data... Importance: High Hi Listserv: The newsgroup told me you were the guy to ask this question, so far I haven't been able to solve it, neither my newsgroup... I have a SPSS table that looks like this. ID Q1 Q2 Q3 ================== 1 4 7 8 1 7 10 12 1 8 14 18 2 11 22 33 2 18 21 9 2 7 7 9 And I would like to display it like this. ID Q1.1 Q2.1 Q3.1 Q1.2 Q2.2 Q3.2 Q1.3 Q2.3 Q3.3 ==================================================== 1 4 7 8 7 10 12 8 14 18 2 11 22 33 18 21 9 7 7 9 I always have "3 lines per case" with the respective ID, and would like to have a "one line per case" with variable labels that correspond. Thanks for your time. Regards, Eugenio Grant |
In reply to this post by Edward Boadi
You can look into the aggregate command which will do what you are
looking for. There are also examples here http://www.spsstools.net/SampleSyntax.htm#RestructureFile Jeff > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] > On Behalf Of Edward Boadi > Sent: Tuesday, November 21, 2006 11:21 AM > To: [hidden email] > Subject: Re: Rearranging Data... > > > Hi Eugenio, > > You wrote : > > EG>I received a message that says "casestovars" is not a > valid command. > EG>I have SPSS 8, could this be the problem? Is there a > different name > EG>for the command on SPSS 8. > > I am using SPSS V 14.0 . I dont think SPSS 8 has the > "casestovars" command (I stand to be corrected). My be > somebody on this will be able to advice on how you could do > that in SPSS 8.0 . > > Thanks. > > Edward. > > -----Original Message----- > From: Eugenio Grant [mailto:[hidden email]] > Sent: Tuesday, November 21, 2006 11:14 AM > To: Edward Boadi > Subject: RE: Rearranging Data... > > > Hi: > > I received a message that says "casestovars" is not a valid > command. I have SPSS 8, could this be the problem? > > Is there a different name for the command on SPSS 8. > > Thanks for your time!!! > > ______________________________ > > Eugenio Grant Mora > Investigación de Medios > Ipsos Costa Rica > Tel 257-0304 > > -----Mensaje original----- > De: Edward Boadi [mailto:[hidden email]] > Enviado el: Martes, 21 de Noviembre de 2006 09:55 a.m. > Para: Eugenio Grant; [hidden email] > Asunto: RE: Rearranging Data... > > Hi Eugenio, > > The syntax below does what you want. > > > SORT CASES BY Id . > CASESTOVARS > /ID = Id > /GROUPBY = VARIABLE . > > > Thanks . > > Edward. > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]]On > Behalf Of Eugenio Grant > Sent: Tuesday, November 21, 2006 10:24 AM > To: [hidden email] > Subject: Rearranging Data... > Importance: High > > > Hi Listserv: > > > > The newsgroup told me you were the guy to ask this question, > so far I haven't been able to solve it, neither my newsgroup... > > > > I have a SPSS table that looks like this. > > > > ID Q1 Q2 Q3 > > ================== > > 1 4 7 8 > > 1 7 10 12 > > 1 8 14 18 > > 2 11 22 33 > > 2 18 21 9 > > 2 7 7 9 > > > > And I would like to display it like this. > > > > ID Q1.1 Q2.1 Q3.1 Q1.2 Q2.2 Q3.2 Q1.3 > Q2.3 Q3.3 > > ==================================================== > > 1 4 7 8 7 10 > 12 8 > 14 18 > > 2 11 22 33 18 21 > 9 7 > 7 9 > > > > > > I always have "3 lines per case" with the respective ID, and > would like to have a "one line per case" with variable labels > that correspond. > > > > Thanks for your time. > > > > Regards, > > Eugenio Grant > |
In reply to this post by Edward Boadi
Hi Eugenio,
Did you look in the manual (pdf) or the help file (F1) already? It could tell you whether casestovars was already implemented or not in v8. Cheers! Albert-Jan --- Edward Boadi <[hidden email]> wrote: > Hi Eugenio, > > You wrote : > > EG>I received a message that says "casestovars" is > not a valid command. I have > EG>SPSS 8, could this be the problem? > EG>Is there a different name for the command on SPSS > 8. > > I am using SPSS V 14.0 . I dont think SPSS 8 has the > "casestovars" command (I stand to be corrected). > My be somebody on this will be able to advice on how > you could do that in SPSS 8.0 . > > Thanks. > > Edward. > > -----Original Message----- > From: Eugenio Grant > [mailto:[hidden email]] > Sent: Tuesday, November 21, 2006 11:14 AM > To: Edward Boadi > Subject: RE: Rearranging Data... > > > Hi: > > I received a message that says "casestovars" is not > a valid command. I have > SPSS 8, could this be the problem? > > Is there a different name for the command on SPSS 8. > > Thanks for your time!!! > > ______________________________ > > Eugenio Grant Mora > Investigación de Medios > Ipsos Costa Rica > Tel 257-0304 > > -----Mensaje original----- > De: Edward Boadi [mailto:[hidden email]] > Enviado el: Martes, 21 de Noviembre de 2006 09:55 > a.m. > Para: Eugenio Grant; [hidden email] > Asunto: RE: Rearranging Data... > > Hi Eugenio, > > The syntax below does what you want. > > > SORT CASES BY Id . > CASESTOVARS > /ID = Id > /GROUPBY = VARIABLE . > > > Thanks . > > Edward. > > -----Original Message----- > From: SPSSX(r) Discussion > [mailto:[hidden email]]On Behalf Of > Eugenio Grant > Sent: Tuesday, November 21, 2006 10:24 AM > To: [hidden email] > Subject: Rearranging Data... > Importance: High > > > Hi Listserv: > > > > The newsgroup told me you were the guy to ask this > question, so far I > haven't been able to solve it, neither my > newsgroup... > > > > I have a SPSS table that looks like this. > > > > ID Q1 Q2 Q3 > > ================== > > 1 4 7 8 > > 1 7 10 12 > > 1 8 14 18 > > 2 11 22 33 > > 2 18 21 9 > > 2 7 7 9 > > > > And I would like to display it like this. > > > > ID Q1.1 Q2.1 Q3.1 Q1.2 Q2.2 > Q3.2 Q1.3 > Q2.3 Q3.3 > > ==================================================== > > 1 4 7 8 7 > 10 12 8 > 14 18 > > 2 11 22 33 18 > 21 9 7 > 7 9 > > > > > > I always have "3 lines per case" with the respective > ID, and would like to > have a "one line per case" with variable labels that > correspond. > > > > Thanks for your time. > > > > Regards, > > Eugenio Grant > ____________________________________________________________________________________ Sponsored Link Compare mortgage rates for today. Get up to 5 free quotes. www2.nextag.com |
In reply to this post by Eugenio Grant
At 10:24 AM 11/21/2006, Eugenio Grant wrote:
>I have a SPSS table that looks like this. > >ID Q1 Q2 Q3 >================== >1 4 7 8 >1 7 10 12 >1 8 14 1 >2 11 22 33 >2 18 21 9 >2 7 7 9 > > >And I would like to display it like this. >ID Q1.1 Q2.1 Q3.1 Q1.2 Q2.2 Q3.2 Q1.3 Q2.3 Q3.3 >==================================================== >1 4 7 8 7 10 12 8 14 18 >2 11 22 33 18 21 9 7 7 9 Sure. But before I do, . The original 'long' data organization can be more useful than the 'wide' one you want to transform to for a lot of uses. At least, keep the 'long' one around for when you need it. . You have an additional problem: there's no record identifier within the case ID. If your records for, say, ID=1 get into the wrong order, you'll get the wrong first record. However, it's a very simple CASESTOVARS command; see below (SPSS draft output, release 14, files not kept separately). I clicked up the CASESTOVARS as follows: Menu Data>Restructure On the panels, 1. Select "Restructure selected cases into variables" 2. Select 'ID' as identifier variable; do not select Q1, Q2 or Q3 in either category 3. Do not specify the cases be sorted 4. Select "Group by index". LIST. |-----------------------------|---------------------------| |Output Created |21-NOV-2006 11:50:13 | |-----------------------------|---------------------------| ID Q1 Q2 Q3 1 4 7 8 1 7 10 12 1 8 14 18 2 11 22 33 2 18 21 9 2 7 7 9 Number of cases read: 6 Number of cases listed: 6 CASESTOVARS /ID = ID /GROUPBY = INDEX . Cases to Variables |--------------------------|---------------------------| |Output Created |21-NOV-2006 11:54:13 | |--------------------------|---------------------------| Generated Variables |---------|------| |Original |Result| |Variabl |------| |e |Name | |-------|-|------| |Q1 |1|Q1.1 | | |2|Q1.2 | | |3|Q1.3 | |-------|-|------| |Q2 |1|Q2.1 | | |2|Q2.2 | | |3|Q2.3 | |-------|-|------| |Q3 |1|Q3.1 | | |2|Q3.2 | | |3|Q3.3 | |-------|-|------| Processing Statistics |---------------|---| |Cases In |6 | |Cases Out |2 | |---------------|---| |Cases In/Cases |3.0| |Out | | |---------------|---| |Variables In |4 | |Variables Out |10 | |---------------|---| |Index Values |3 | |---------------|---| LIST. |-----------------------------|---------------------------| |Output Created |21-NOV-2006 11:54:29 | |-----------------------------|---------------------------| ID Q1.1 Q2.1 Q3.1 Q1.2 Q2.2 Q3.2 Q1.3 Q2.3 Q3.3 1 4 7 8 7 10 12 8 14 18 2 11 22 33 18 21 9 7 7 9 Number of cases read: 2 Number of cases listed: 2 Appendix - test data: -------------------- DATA LIST LIST / ID Q1 Q2 Q3. BEGIN DATA. 1 4 7 8 1 7 10 12 1 8 14 18 2 11 22 33 2 18 21 9 2 7 7 9 END DATA. FORMATS ID TO Q3 (F3). |
In reply to this post by Eugenio Grant
Hi Richard,
Eugenio is using SPSS V 8.0 . Thanks. Edward. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Richard Ristow Sent: Tuesday, November 21, 2006 12:25 PM To: [hidden email] Subject: Re: Rearranging Data... At 10:24 AM 11/21/2006, Eugenio Grant wrote: >I have a SPSS table that looks like this. > >ID Q1 Q2 Q3 >================== >1 4 7 8 >1 7 10 12 >1 8 14 1 >2 11 22 33 >2 18 21 9 >2 7 7 9 > > >And I would like to display it like this. >ID Q1.1 Q2.1 Q3.1 Q1.2 Q2.2 Q3.2 Q1.3 Q2.3 Q3.3 >==================================================== >1 4 7 8 7 10 12 8 14 18 >2 11 22 33 18 21 9 7 7 9 Sure. But before I do, . The original 'long' data organization can be more useful than the 'wide' one you want to transform to for a lot of uses. At least, keep the 'long' one around for when you need it. . You have an additional problem: there's no record identifier within the case ID. If your records for, say, ID=1 get into the wrong order, you'll get the wrong first record. However, it's a very simple CASESTOVARS command; see below (SPSS draft output, release 14, files not kept separately). I clicked up the CASESTOVARS as follows: Menu Data>Restructure On the panels, 1. Select "Restructure selected cases into variables" 2. Select 'ID' as identifier variable; do not select Q1, Q2 or Q3 in either category 3. Do not specify the cases be sorted 4. Select "Group by index". LIST. |-----------------------------|---------------------------| |Output Created |21-NOV-2006 11:50:13 | |-----------------------------|---------------------------| ID Q1 Q2 Q3 1 4 7 8 1 7 10 12 1 8 14 18 2 11 22 33 2 18 21 9 2 7 7 9 Number of cases read: 6 Number of cases listed: 6 CASESTOVARS /ID = ID /GROUPBY = INDEX . Cases to Variables |--------------------------|---------------------------| |Output Created |21-NOV-2006 11:54:13 | |--------------------------|---------------------------| Generated Variables |---------|------| |Original |Result| |Variabl |------| |e |Name | |-------|-|------| |Q1 |1|Q1.1 | | |2|Q1.2 | | |3|Q1.3 | |-------|-|------| |Q2 |1|Q2.1 | | |2|Q2.2 | | |3|Q2.3 | |-------|-|------| |Q3 |1|Q3.1 | | |2|Q3.2 | | |3|Q3.3 | |-------|-|------| Processing Statistics |---------------|---| |Cases In |6 | |Cases Out |2 | |---------------|---| |Cases In/Cases |3.0| |Out | | |---------------|---| |Variables In |4 | |Variables Out |10 | |---------------|---| |Index Values |3 | |---------------|---| LIST. |-----------------------------|---------------------------| |Output Created |21-NOV-2006 11:54:29 | |-----------------------------|---------------------------| ID Q1.1 Q2.1 Q3.1 Q1.2 Q2.2 Q3.2 Q1.3 Q2.3 Q3.3 1 4 7 8 7 10 12 8 14 18 2 11 22 33 18 21 9 7 7 9 Number of cases read: 2 Number of cases listed: 2 Appendix - test data: -------------------- DATA LIST LIST / ID Q1 Q2 Q3. BEGIN DATA. 1 4 7 8 1 7 10 12 1 8 14 18 2 11 22 33 2 18 21 9 2 7 7 9 END DATA. FORMATS ID TO Q3 (F3). |
In reply to this post by Eugenio Grant
Shalom
Here is a simple way how to change your data from long to wide in spss 8 . (the input file have to be sorted on the id variable before you run the program) . run name 'create 3 file from alldata and match them' . GET FILE=alldata.sav . compute seq=$casenum . compute seq=mod(seq+2,3) +1 . do if seq= 1 . xsave outfile=file1.sav . else if seq= 2 . xsave outfile=file2.sav. else if seq= 3 . xsave outfile=file3.sav . end if. execute. match files file=file1.sav / file=file2.sav / file=file3.sav /by id . execute. Hillel Vardi Eugenio Grant wrote: > Hi Listserv: > > > > The newsgroup told me you were the guy to ask this question, so far I > haven't been able to solve it, neither my newsgroup... > > > > I have a SPSS table that looks like this. > > > > ID Q1 Q2 Q3 > > ================== > > 1 4 7 8 > > 1 7 10 12 > > 1 8 14 18 > > 2 11 22 33 > > 2 18 21 9 > > 2 7 7 9 > > > > And I would like to display it like this. > > > > ID Q1.1 Q2.1 Q3.1 Q1.2 Q2.2 Q3.2 Q1.3 > Q2.3 Q3.3 > > ==================================================== > > 1 4 7 8 7 10 12 8 > 14 18 > > 2 11 22 33 18 21 9 7 > 7 9 > > > > > > I always have "3 lines per case" with the respective ID, and would like to > have a "one line per case" with variable labels that correspond. > > > > Thanks for your time. > > > > Regards, > > Eugenio Grant > > |
At 03:47 AM 11/22/2006, hillel wrote:
> Here is a simple way how to change your data from long to wide in > spss 8 . > >run name 'create 3 file from alldata and match them' . >GET FILE=alldata.sav . >compute seq=$casenum . >compute seq=mod(seq+2,3) +1 . >do if seq= 1 . >xsave outfile=file1.sav . >else if seq= 2 . >xsave outfile=file2.sav. >else if seq= 3 . >xsave outfile=file3.sav . >end if. >execute. >match files file=file1.sav / file=file2.sav / file=file3.sav > /by id . It's an excellent idea, but has this code been tested? It looks like you'll only get your variables from file3, because the data variables have the same names in all three files. |
Hi all,
I'm experiencing a glitch with the Output Window in SPSS 15. Not all output is visible in the window, but I can see it all when I do a Print Preview or actually print or export to PDF. This seems to happen after I do a bit of cut & pasting to rearrange the order of the tables and/or charts. In one case, I had two tables that looked like they were superimposed. The tables are toggled as Visible, but neither clicking on the object in the outline pane or scrolling through the output brings it up. If I open a new Output Window and paste the previously hidden tables into that, then everything is visible again. Anyone out there have any thoughts on why this is happening? Thanks Victor Kogler |
Perhaps you're talking about pivot tables that are one beneath the
other? If you order AGE BY SEX BY TOWN, you get one table of AGE BY SEX for each town, but you see only the one for the first town, all the others being beneath. They all are exported as successive tables in Excel or HTML or PDF, or you can toggle between them by double clicking on them in the Output window to go into edit mode. Thios varies somehow in different versions, though. Hector -----Mensaje original----- De: SPSSX(r) Discussion [mailto:[hidden email]] En nombre de Victor Kogler Enviado el: 22 November 2006 21:02 Para: [hidden email] Asunto: Output Window Weirdness Hi all, I'm experiencing a glitch with the Output Window in SPSS 15. Not all output is visible in the window, but I can see it all when I do a Preview or actually print or export to PDF. This seems to happen after I do a bit of cut & pasting to rearrange the order of the tables and/or charts. In one case, I had two tables that looked like they were superimposed. The tables are toggled as Visible, but neither clicking on the object in the outline pane or scrolling through the output brings it up. If I open a new Output Window and paste the previously hidden tables into that, then everything is visible again. Anyone out there have any thoughts on why this is happening? Thanks Victor Kogler |
Free forum by Nabble | Edit this page |