|
Hello and happy Friday to the SPSSlist,
I have a dataset where each row represents a student. I would like to assign a number to each student based on the name of the student's teacher (a string variable). This is easy to do when there are only a few teachers: IF (ClassName EQ 'DURRETT') Teachid = 9001. IF (ClassName EQ 'KING') Teachid = 9002., etc., but it becomes time consuming with lots of teachers. The number used doesn't matter, but if they could all be the same number of digits, that would be ideal. For example, if the numbers are 1 through 200, teacher 1 will need to be labeled 001, not 1. Also, it would be best if no numbers started with 0, so 001 might become 9001. Is this something that SPSS can do? Where do I start? ____________________________________ Justin Meyer Researcher Rowland Reading Foundation ====================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 |
|
I figured out a method for doing this. I discovered Automatic Recode and
used it on the variable that represents the name of the teacher. Then I used compute to add 9000 to the result of the automatic recode. Have a nice weekend everyone. ____________________________________ Justin Meyer Rowland Reading Foundation phone: 866-370-7323 fax: 608-204-3846 ____________________________________ From: Justin Meyer Sent: Friday, November 07, 2008 4:31 PM To: [hidden email] Subject: How to Assign a Numeric Value by Group? Hello and happy Friday to the SPSSlist, I have a dataset where each row represents a student. I would like to assign a number to each student based on the name of the student's teacher (a string variable). This is easy to do when there are only a few teachers: IF (ClassName EQ 'DURRETT') Teachid = 9001. IF (ClassName EQ 'KING') Teachid = 9002., etc., but it becomes time consuming with lots of teachers. The number used doesn't matter, but if they could all be the same number of digits, that would be ideal. For example, if the numbers are 1 through 200, teacher 1 will need to be labeled 001, not 1. Also, it would be best if no numbers started with 0, so 001 might become 9001. Is this something that SPSS can do? Where do I start? ____________________________________ Justin Meyer Researcher Rowland Reading Foundation ====================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 |
|
In reply to this post by Justin Meyer-3
try this
autorecode variables = teacher /into n_teacher/print. Art Kendall Social Research Consultants Justin Meyer wrote: > Hello and happy Friday to the SPSSlist, > > > > I have a dataset where each row represents a student. I would like to > assign a number to each student based on the name of the student's > teacher (a string variable). This is easy to do when there are only a > few teachers: IF (ClassName EQ 'DURRETT') Teachid = 9001. > > IF (ClassName EQ 'KING') Teachid = 9002., etc., but it becomes time > consuming with lots of teachers. > > > > The number used doesn't matter, but if they could all be the same number > of digits, that would be ideal. For example, if the numbers are 1 > through 200, teacher 1 will need to be labeled 001, not 1. Also, it > would be best if no numbers started with 0, so 001 might become 9001. > > > > Is this something that SPSS can do? Where do I start? > > > > ____________________________________ > > Justin Meyer > > Researcher > > Rowland Reading Foundation > > > > =================== > 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
Art Kendall
Social Research Consultants |
|
In reply to this post by Justin Meyer-3
How about:
autorecode variables=classname /into teachid. compute teachid=(9000+teachid). formats teachid (f4). The original values of classname will be used as value labels for the new numeric variable teachid. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Justin Meyer Sent: Friday, November 07, 2008 4:31 PM To: [hidden email] Subject: How to Assign a Numeric Value by Group? Hello and happy Friday to the SPSSlist, I have a dataset where each row represents a student. I would like to assign a number to each student based on the name of the student's teacher (a string variable). This is easy to do when there are only a few teachers: IF (ClassName EQ 'DURRETT') Teachid = 9001. IF (ClassName EQ 'KING') Teachid = 9002., etc., but it becomes time consuming with lots of teachers. The number used doesn't matter, but if they could all be the same number of digits, that would be ideal. For example, if the numbers are 1 through 200, teacher 1 will need to be labeled 001, not 1. Also, it would be best if no numbers started with 0, so 001 might become 9001. Is this something that SPSS can do? Where do I start? ____________________________________ Justin Meyer Researcher Rowland Reading Foundation ======= 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 |
| Free forum by Nabble | Edit this page |
