|
I'm having trouble creating a graph that I think should be fairly
simple. But it is starting to annoy me that I can't figure it out. I have a variable at time 1 and the same variable at time 2. I want to see all the individual change lines. So time 1 on the left side of the X axis and time 2 on the right side of the X axis. The Y axis will be the common metric for the variable. Some lines will be going up, some going down, some flat, all depending on how they change. Thanks Jeff ===================== 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 |
|
Is something like this what you are looking for (tested SPSS 15):
DATA LIST FREE /CASE (F1) TIME (A2) VALUE (F2). BEGIN DATA 1 T1 3 1 T2 6 2 T1 4 2 T2 4 3 T1 8 3 T2 3 END DATA. EXE. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=TIME VALUE CASE MISSING= LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: TIME=col(source(s), name("TIME"), unit.category()) DATA: VALUE=col(source(s), name("VALUE"), unit.category()) DATA: CASE=col(source(s), name("CASE"), unit.category()) GUIDE: axis(dim(1), label("TIME")) GUIDE: axis(dim(2), label("VALUE")) GUIDE: legend(aesthetic(aesthetic.color.interior), label("CASE")) SCALE: cat(dim(1)) SCALE: cat(dim(2)) SCALE: cat(aesthetic(aesthetic.color.interior)) ELEMENT: line(position(TIME*VALUE), color.interior(CASE), missing.wings()) END GPL. Luca Mr. Luca MEYER Market research, data analysis & more www.lucameyer.com - Tel: +39.339.495.00.21 -----Messaggio originale----- Da: SPSSX(r) Discussion [mailto:[hidden email]] Per conto di Jeff Stuewig Inviato: sabato 8 dicembre 2007 22.38 A: [hidden email] Oggetto: Creating a graph I'm having trouble creating a graph that I think should be fairly simple. But it is starting to annoy me that I can't figure it out. I have a variable at time 1 and the same variable at time 2. I want to see all the individual change lines. So time 1 on the left side of the X axis and time 2 on the right side of the X axis. The Y axis will be the common metric for the variable. Some lines will be going up, some going down, some flat, all depending on how they change. Thanks Jeff ===================== 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 No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.16.17/1178 - Release Date: 08/12/2007 11.59 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.16.17/1178 - Release Date: 08/12/2007 11.59 ===================== 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 |
|
Luca,
Yes, thank you very much. Below is some syntax that ViAnn Beadle sent me as well which I found very useful. Jeff *********************************************** OK, what you have here is a "summaries of separate variables" chart except that you need to flip the pseudo-index variable. Basically, if you conceptualized this as you had two rows of data, Y for time1 and Y for time2 along with an index variable this would basically be just be Y on Y, Index on X and some user-id variable for each individual line. You have two different approaches to get this chart. You could use the VARSTOCASES procedure to restructure the data and then make the assignments as described here. Or you could use GGRAPH command to do the restructuring on the fly. Here are examples of both ways of doing this with this sample data. data list list / caseid time1 time2. Begin data. 1 1 1 2 3 6 3 7 5 4 8 2 5 3 3 End data. SAVE OUTFILE='C:\Users\Vi\Documents\original.sav' /COMPRESSED. * restructure from variables to cases. VARSTOCASES /ID=id /MAKE trans1 FROM time1 time2 /INDEX=Index1(2) /KEEP= /NULL=KEEP. variable labels index1 "Time" / trans1 "Score". value labels index1 1 "Time 1" 2 "Time 2". * Chart Builder. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=Index1 trans1 id MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: Index1=col(source(s), name("Index1"), unit.category()) DATA: trans1=col(source(s), name("trans1"), unit.category()) DATA: id=col(source(s), name("id"), unit.category()) GUIDE: axis(dim(1), label("Time")) GUIDE: axis(dim(2), label("Score")) GUIDE: legend(aesthetic(aesthetic.color.interior), label("id")) SCALE: cat(dim(1), include("1", "2")) ELEMENT: line(position(Index1*trans1), color.interior(id), missing.wings()) END GPL. * second approach is to do the restructure inside GGRAPH. I have to retrieve the original data since VARSTOCASES replaced it. GET FILE='C:\Users\Vi\Documents\original.sav'. * Chart Builder. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=MEAN(time1) MEAN(time2) caseid MISSING=LISTWISE REPORTMISSING=NO TRANSFORM=VARSTOCASES(SUMMARY="#SUMMARY" INDEX="#INDEX") /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: SUMMARY=col(source(s), name("#SUMMARY")) DATA: INDEX=col(source(s), name("#INDEX"), unit.category()) DATA: caseid=col(source(s), name("caseid"), unit.category()) GUIDE: axis(dim(1), label("Time")) GUIDE: axis(dim(2), label("Score")) GUIDE: legend(aesthetic(aesthetic.color.interior), label("caseid")) SCALE: cat(dim(1), include("0", "1")) SCALE: linear(dim(2), include(0)) ELEMENT: line(position(INDEX*SUMMARY), color.interior(caseid), missing.wings()) END GPL. ----- Original Message ----- From: Luca Meyer <[hidden email]> Date: Sunday, December 9, 2007 1:56 am Subject: R: Creating a graph > Is something like this what you are looking for (tested SPSS 15): > > DATA LIST FREE /CASE (F1) TIME (A2) VALUE (F2). > BEGIN DATA > 1 T1 3 > 1 T2 6 > 2 T1 4 > 2 T2 4 > 3 T1 8 > 3 T2 3 > END DATA. > EXE. > > GGRAPH > /GRAPHDATASET NAME="graphdataset" VARIABLES=TIME VALUE CASE MISSING= > LISTWISE REPORTMISSING=NO > /GRAPHSPEC SOURCE=INLINE. > BEGIN GPL > SOURCE: s=userSource(id("graphdataset")) > DATA: TIME=col(source(s), name("TIME"), unit.category()) > DATA: VALUE=col(source(s), name("VALUE"), unit.category()) > DATA: CASE=col(source(s), name("CASE"), unit.category()) > GUIDE: axis(dim(1), label("TIME")) > GUIDE: axis(dim(2), label("VALUE")) > GUIDE: legend(aesthetic(aesthetic.color.interior), label("CASE")) > SCALE: cat(dim(1)) > SCALE: cat(dim(2)) > SCALE: cat(aesthetic(aesthetic.color.interior)) > ELEMENT: line(position(TIME*VALUE), color.interior(CASE), > missing.wings())END GPL. > > Luca > > Mr. Luca MEYER > Market research, data analysis & more > www.lucameyer.com - Tel: +39.339.495.00.21 > > > -----Messaggio originale----- > Da: SPSSX(r) Discussion [mailto:[hidden email]] Per > conto di Jeff > Stuewig > Inviato: sabato 8 dicembre 2007 22.38 > A: [hidden email] > Oggetto: Creating a graph > > I'm having trouble creating a graph that I think should be > fairlysimple. But it is starting to annoy me that I can't figure > it out. > I have a variable at time 1 and the same variable at time > 2. I want > to see all the individual change lines. So time 1 on the left > side of the X > axis and time 2 on the right side of the X axis. The Y axis will > be the > common metric for the variable. Some lines will be going up, some > goingdown, some flat, all depending on how they change. > > Thanks > > Jeff > ===================== 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 |
