|
Hello Art and David,
Thanks for all your help with my data needs It worked quite well for dichotomous data as presented in the example I posted. Now, I have a question regarding a situation where the data is valued (not dichotomous). For example, where the value indicates maybe frequency of playing with each other. The new data set up is pasted below:
ColumnA ColumnB ColumnC
ClassA OtherStud WorkWith
AA DD 10
AA EE 5
AA BB 20
BB CC 4
BB AA 20
BB KK 0
CC AA 50
CC BB 14
ColumnA refers to students in ClassroomA, and Column B refers to "Other
Students" in the school who could act as work and/or playmates. Column C records the frequency of play interactions.
Note, ColumnB also includes some of the same students in ColumnA(ClassA) who work with each other (For example, Students: AA and BB).
If a Student in Classroom A works with a student in ClassroomB, ColumnC
takes the value that records the frequency of interaction between students in Classroom A and Classroom B.
So, looking at ColumnA, we find that there are three students: AA, BB and
CC. Student_AA for instance interacts with three students <DD, EE, BB>. For instance, Student_AA plays with Student_DD 10 times, and with Student_EE 5 times.
Now, I am interested in constructing a matrix indicating how frequent any pairs of students play with each other. The resulting matrix for the "Plays With" relation (ColumnC) among the 3 students unique to ClassroomA and ClassroomB would look like this:
AA BB CC
AA 0 20 0
BB 20 0 4
CC 50 14 0
This matrix is the output I am interested in, and need to produce for the relationship specified in Column C. The matrix would have to be square and consist of students that are members of BOTH classrooms A and B.
I would certainly appreciate some ideas to help me produce this.Thanks in advance for your assistance. Sincerely, Cy |
|
Administrator
|
Cy,
My suggestion is try to generalize it yourself using the previous help you received. If you get stuck then post what you have tried. David ===================== 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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
|
David,
Thanks -- I actually played with the code a bit, but it did not help much. The code i used is pasted below. I changed the <Link> value from "EQ" to GE (greater than or equal) to one - so that it can populate the cells appropriately. But this did not help -- it still produced the matrix based on 1s or 0s.
Thanks - Cy ===> data list list/rowkid (a2) colkid(a2) link(f1). begin data AA DD 10
AA EE 5 AA BB 20 BB CC 4 BB AA 20
BB KK 0 CC AA 50 CC BB 14 end data. autorecode variables = rowkid colkid /into nrowkid ncolkid /group.
select if link GT 1. * Custom Tables. CTABLES /VLABELS VARIABLES=nrowkid ncolkid DISPLAY=BOTH /TABLE nrowkid BY ncolkid [COUNT F40.0] /CATEGORIES VARIABLES=nrowkid ncolkid ORDER=A KEY=VALUE EMPTY=INCLUDE.
===> On Wed, Nov 3, 2010 at 6:21 PM, David Marso <[hidden email]> wrote: Cy, |
|
Administrator
|
In reply to this post by Chao Yawo
Cy,
You don't need the autorecode (I thought you were initially after a data set (hence AGGREGATE etc in previous solution). In this case you should use something other than COUNT for the TABLE stats (or weight the data by link). OTOH: CTABLES /FORMAT MISSING='0' /VLABELS VARIABLES=colkid rowkid link DISPLAY=DEFAULT /TABLE rowkid > link [MEAN ' '] BY colkid /CATEGORIES VARIABLES=colkid rowkid ORDER=A KEY=VALUE . should get you close. David On Wed, 3 Nov 2010 20:30:17 -0400, Chao Yawo <[hidden email]> wrote: >David, > >Thanks -- I actually played with the code a bit, but it did not help much. > The code i used is pasted below. I changed the <Link> value from "EQ" to >GE (greater than or equal) to one - so that it can populate the cells >appropriately. But this did not help -- it still produced the matrix based >on 1s or 0s. > >Thanks - Cy > >===> > >data list list/rowkid (a2) colkid(a2) link(f1). >begin data >AA DD 10 >AA EE 5 >AA BB 20 >BB CC 4 >BB AA 20 >BB KK 0 >CC AA 50 >CC BB 14 >end data. >autorecode variables = rowkid colkid /into nrowkid ncolkid /group. >select if link GT 1. > >* Custom Tables. >CTABLES > /VLABELS VARIABLES=nrowkid ncolkid DISPLAY=BOTH > /TABLE nrowkid BY ncolkid [COUNT F40.0] > /CATEGORIES VARIABLES=nrowkid ncolkid ORDER=A KEY=VALUE EMPTY=INCLUDE. > >===> > >On Wed, Nov 3, 2010 at 6:21 PM, David Marso <[hidden email]> wrote: > >> Cy, >> My suggestion is try to generalize it yourself using the previous help you >> received. If you get stuck then post what you have tried. >> David >> >> ===================== >> 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 >> > ===================== 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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
|
I know the use of RTRIM and LTRIM for leading and extra spacing at
the end.� I tried using REPLACE but SPSS wouldn't recognize the
spaces as something to replace (indeed it would replace spaces at
the end but not those in between.� This is a text file pulled in to
spss.� I want to transpose the data (CASESTOVARS) but it balks at
the ones that inserted space ("J4� � � � � � � � 2")� and renames them v1,
v2, etc:
GET DATA� /TYPE = TXT � /FILE = 'PR.txt' � /FIXCASE = 1 � /ARRANGEMENT = FIXED � /FIRSTCASE = 1 � /IMPORTCASE = ALL � /VARIABLES = � /1� respnum$ 0-8 F9.0 � Qname 9-21 A13 � Qtext 22-2018 A2000. save outfile "c:\temp_o.sav". GET file "c:\temp_o.sav". * transpose data. compute Qtext=ltrim(Qtext). exe. if substr(Qtext,1,6) <> "(note)"� Qname=concat(rtrim(Qname),"_opn"). if substr(Qtext,1,6) = "(note)" Qname=concat(rtrim(Qname),"_note"). exe. SORT CASES BY respnum$ Qname . CASESTOVARS � /ID = respnum$ � /INDEX = Qname � /GROUPBY = VARIABLE . Any idea how to tell it to eliminate the space and replace it with an underscore "_"? Thanks. JLH |
|
|
To find out what those "spaces"
really are, change the variable format to AHEX:
FORMAT x (AHEXnn). where nn is twice the declared field width of variable x. In the resulting display in the Data Editor, blanks will appear as 20. If you see any values lower than 20, they are nonprinting characters and will not match a blank. Jon Peck Senior Software Engineer, IBM [hidden email] 312-651-3435 From: Albert-Jan Roskam <[hidden email]> To: [hidden email] Date: 11/05/2010 03:05 AM Subject: Re: [SPSSX-L] Help with trimming spaces in string variable Sent by: "SPSSX(r) Discussion" <[hidden email]>
|
| Free forum by Nabble | Edit this page |
