|
Hi everyone,
I have a database in which the data entry staff entered the responses to one question in four different columns. I would like to combine it all into one column. The syntax I have so far is the following: RECODE q3_1a (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . VARIABLE LABELS new3_1 'Clean table or tray'. EXECUTE . SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into new3_1. I don't have to worry about any response overriding another one because each response is affiliated with a different person. I am trying to avoid doing frequencies of each and tallying it up the total by hand. Is there a syntax that will allow me to recode multiple variables into one variable? Thanks so much, Deepa ===================== 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 |
|
Search for multiple response in the HELP system. The MULT RESPONSE
procedure, CTABLES, and TABLES all tabulate multiple variables into a single frequency table. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Deepa Bhat Sent: Wednesday, January 30, 2008 9:12 AM To: [hidden email] Subject: Recoding multiple variables into one new variable Hi everyone, I have a database in which the data entry staff entered the responses to one question in four different columns. I would like to combine it all into one column. The syntax I have so far is the following: RECODE q3_1a (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . VARIABLE LABELS new3_1 'Clean table or tray'. EXECUTE . SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into new3_1. I don't have to worry about any response overriding another one because each response is affiliated with a different person. I am trying to avoid doing frequencies of each and tallying it up the total by hand. Is there a syntax that will allow me to recode multiple variables into one variable? Thanks so much, Deepa ===================== 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 |
|
In reply to this post by Deepa Bhat
Deepa,
I don't know if this is the best method, but you can do that by using a different RECODE command for each of the original variables (tested in v.16): RECODE q3_1a (1=1) (2=2) (99=99) INTO new3_1 . RECODE q3_1b (1=1) (2=2) (99=99) INTO new3_1 . RECODE q3_1c (1=1) (2=2) (99=99) INTO new3_1 . RECODE q3_1d (1=1) (2=2) (99=99) INTO new3_1 . VARIABLE LABELS new3_1 'Clean table or tray'. EXECUTE . A couple of points to remember: 1. This will only work if you don't have rows with data in more than one column. If you do, then the latter variable will overwrite the previous one. 2. I haven't included the SYSMIS values in the code. I've done this because I'm assuming that if the first row might have "2" for q3_1a but have SYSMIS for all the other three vars. If that is true, then the code will overwrite "2" with SYSMIS in new3_1. HTH. Shahrukh > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Deepa Bhat > Sent: Wednesday, January 30, 2008 10:12 AM > To: [hidden email] > Subject: Recoding multiple variables into one new variable > > Hi everyone, > > I have a database in which the data entry staff entered the responses > to one question in four different columns. I would like to combine it > all into one column. The syntax I have so far is the following: > > RECODE > q3_1a > (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . > VARIABLE LABELS new3_1 'Clean table or tray'. > EXECUTE . > > > SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into > new3_1. I don't have to worry about any response overriding another > because each response is affiliated with a different person. > > I am trying to avoid doing frequencies of each and tallying it up the > total by hand. Is there a syntax that will allow me to recode multiple > variables into one variable? > > Thanks so much, > Deepa > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except > 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 |
|
Hi there,
there is simpler solution to recode RECODE q3_1a q3_1b q3_1c (1=1) (2=2) (99=99) INTO new3_1 new3_1 new3_1 . execute. and also there is SUM Compute new3_1=SUM(q3_1a,q3_1b,q3_1c). execute. Of course both methods assume there is only one value in each row so it is not actual multiple answer. BR Samir > Deepa, > > I don't know if this is the best method, but you can do that by using a > different RECODE command for each of the original variables (tested in > v.16): > > RECODE > q3_1a > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1b > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1c > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1d > (1=1) (2=2) (99=99) INTO new3_1 . > VARIABLE LABELS new3_1 'Clean table or tray'. > EXECUTE . > > > A couple of points to remember: > 1. This will only work if you don't have rows with data in more than one > column. If you do, then the latter variable will overwrite the previous > one. > 2. I haven't included the SYSMIS values in the code. I've done this > because I'm assuming that if the first row might have "2" for q3_1a but > have SYSMIS for all the other three vars. If that is true, then the > code will overwrite "2" with SYSMIS in new3_1. > > HTH. > > > Shahrukh > > > > > >> -----Original Message----- >> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf > Of >> Deepa Bhat >> Sent: Wednesday, January 30, 2008 10:12 AM >> To: [hidden email] >> Subject: Recoding multiple variables into one new variable >> >> Hi everyone, >> >> I have a database in which the data entry staff entered the responses >> to one question in four different columns. I would like to combine it >> all into one column. The syntax I have so far is the following: >> >> RECODE >> q3_1a >> (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . >> VARIABLE LABELS new3_1 'Clean table or tray'. >> EXECUTE . >> >> >> SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into >> new3_1. I don't have to worry about any response overriding another > one >> because each response is affiliated with a different person. >> >> I am trying to avoid doing frequencies of each and tallying it up the >> total by hand. Is there a syntax that will allow me to recode multiple >> variables into one variable? >> >> Thanks so much, >> Deepa >> >> ===================== >> 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 > -- GfK BH Samir Omerovic ===================== 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 Hashmi, Syed S
This definitely will not work. What will happen is that new3_1 will be set
to that last recode executed. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Hashmi, Syed S Sent: Wednesday, January 30, 2008 9:56 AM To: [hidden email] Subject: Re: Recoding multiple variables into one new variable Deepa, I don't know if this is the best method, but you can do that by using a different RECODE command for each of the original variables (tested in v.16): RECODE q3_1a (1=1) (2=2) (99=99) INTO new3_1 . RECODE q3_1b (1=1) (2=2) (99=99) INTO new3_1 . RECODE q3_1c (1=1) (2=2) (99=99) INTO new3_1 . RECODE q3_1d (1=1) (2=2) (99=99) INTO new3_1 . VARIABLE LABELS new3_1 'Clean table or tray'. EXECUTE . A couple of points to remember: 1. This will only work if you don't have rows with data in more than one column. If you do, then the latter variable will overwrite the previous one. 2. I haven't included the SYSMIS values in the code. I've done this because I'm assuming that if the first row might have "2" for q3_1a but have SYSMIS for all the other three vars. If that is true, then the code will overwrite "2" with SYSMIS in new3_1. HTH. Shahrukh > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Deepa Bhat > Sent: Wednesday, January 30, 2008 10:12 AM > To: [hidden email] > Subject: Recoding multiple variables into one new variable > > Hi everyone, > > I have a database in which the data entry staff entered the responses > to one question in four different columns. I would like to combine it > all into one column. The syntax I have so far is the following: > > RECODE > q3_1a > (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . > VARIABLE LABELS new3_1 'Clean table or tray'. > EXECUTE . > > > SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into > new3_1. I don't have to worry about any response overriding another > because each response is affiliated with a different person. > > I am trying to avoid doing frequencies of each and tallying it up the > total by hand. Is there a syntax that will allow me to recode multiple > variables into one variable? > > Thanks so much, > Deepa > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except > 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 ===================== 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 Samir Omerovic
This will definitely not work.
You have two choices with tabulating multiple response variables--use a procedure that understands them or use VARSTOCASES to restructure the file so that each response becomes a new case (total overkill as an approach). -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of [Samir Omeroviæ] Sent: Wednesday, January 30, 2008 9:54 AM To: [hidden email] Subject: Re: Recoding multiple variables into one new variable Hi there, there is simpler solution to recode RECODE q3_1a q3_1b q3_1c (1=1) (2=2) (99=99) INTO new3_1 new3_1 new3_1 . execute. and also there is SUM Compute new3_1=SUM(q3_1a,q3_1b,q3_1c). execute. Of course both methods assume there is only one value in each row so it is not actual multiple answer. BR Samir > Deepa, > > I don't know if this is the best method, but you can do that by using a > different RECODE command for each of the original variables (tested in > v.16): > > RECODE > q3_1a > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1b > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1c > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1d > (1=1) (2=2) (99=99) INTO new3_1 . > VARIABLE LABELS new3_1 'Clean table or tray'. > EXECUTE . > > > A couple of points to remember: > 1. This will only work if you don't have rows with data in more than one > column. If you do, then the latter variable will overwrite the previous > one. > 2. I haven't included the SYSMIS values in the code. I've done this > because I'm assuming that if the first row might have "2" for q3_1a but > have SYSMIS for all the other three vars. If that is true, then the > code will overwrite "2" with SYSMIS in new3_1. > > HTH. > > > Shahrukh > > > > > >> -----Original Message----- >> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf > Of >> Deepa Bhat >> Sent: Wednesday, January 30, 2008 10:12 AM >> To: [hidden email] >> Subject: Recoding multiple variables into one new variable >> >> Hi everyone, >> >> I have a database in which the data entry staff entered the responses >> to one question in four different columns. I would like to combine it >> all into one column. The syntax I have so far is the following: >> >> RECODE >> q3_1a >> (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . >> VARIABLE LABELS new3_1 'Clean table or tray'. >> EXECUTE . >> >> >> SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into >> new3_1. I don't have to worry about any response overriding another > one >> because each response is affiliated with a different person. >> >> I am trying to avoid doing frequencies of each and tallying it up the >> total by hand. Is there a syntax that will allow me to recode multiple >> variables into one variable? >> >> Thanks so much, >> Deepa >> >> ===================== >> 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 > -- GfK BH Samir Omerovic ===================== 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 |
|
In reply to this post by Deepa Bhat
Deepa,
I'm not sure but I think what you are looking for is something like this Compute new3_1=q3_1a. If not(sysmis(q3_1b)) new3_1=q3_1b. If not(sysmis(q3_1c)) new3_1=q3_1c. If not(sysmis(q3_1d)) new3_1=q3_1d. Gene Maguin ===================== 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 |
|
Under the same assumption (no more than one is not sysmis), and assuming for my convenience that the originals are consecutive in the file, you could use
Compute new3_1 = sum(q3_1a to q3_1d). To check that assumption, you could use Do if (nvalid(q3_1a to q3_1d) > 1). Print /"More than one q3_1 response in case ", #casenum. End if. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin Sent: Wednesday, January 30, 2008 11:47 AM To: [hidden email] Subject: Re: Recoding multiple variables into one new variable Deepa, I'm not sure but I think what you are looking for is something like this Compute new3_1=q3_1a. If not(sysmis(q3_1b)) new3_1=q3_1b. If not(sysmis(q3_1c)) new3_1=q3_1c. If not(sysmis(q3_1d)) new3_1=q3_1d. Gene Maguin ===================== 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 |
|
In reply to this post by ViAnn Beadle
This actually works since I have been doing it for a long time. Just try it.
it works since the answers are not multiple answers. if the file is structered like this v1 v2 v3 1 2 3 3 4 5 it works. > This will definitely not work. > > You have two choices with tabulating multiple response variables--use a > procedure that understands them or use VARSTOCASES to restructure the file > so that each response becomes a new case (total overkill as an approach). > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > [Samir Omeroviæ] > Sent: Wednesday, January 30, 2008 9:54 AM > To: [hidden email] > Subject: Re: Recoding multiple variables into one new variable > > Hi there, > > there is simpler solution to recode > > RECODE > q3_1a q3_1b q3_1c > (1=1) (2=2) (99=99) INTO new3_1 new3_1 new3_1 . > execute. > > and also there is SUM > > Compute new3_1=SUM(q3_1a,q3_1b,q3_1c). > execute. > > Of course both methods assume there is only one value in each row so it is > not actual multiple answer. > > BR > Samir > > > >> Deepa, >> >> I don't know if this is the best method, but you can do that by using a >> different RECODE command for each of the original variables (tested in >> v.16): >> >> RECODE >> q3_1a >> (1=1) (2=2) (99=99) INTO new3_1 . >> RECODE >> q3_1b >> (1=1) (2=2) (99=99) INTO new3_1 . >> RECODE >> q3_1c >> (1=1) (2=2) (99=99) INTO new3_1 . >> RECODE >> q3_1d >> (1=1) (2=2) (99=99) INTO new3_1 . >> VARIABLE LABELS new3_1 'Clean table or tray'. >> EXECUTE . >> >> >> A couple of points to remember: >> 1. This will only work if you don't have rows with data in more than one >> column. If you do, then the latter variable will overwrite the previous >> one. >> 2. I haven't included the SYSMIS values in the code. I've done this >> because I'm assuming that if the first row might have "2" for q3_1a but >> have SYSMIS for all the other three vars. If that is true, then the >> code will overwrite "2" with SYSMIS in new3_1. >> >> HTH. >> >> >> Shahrukh >> >> >> >> >> >>> -----Original Message----- >>> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >> Of >>> Deepa Bhat >>> Sent: Wednesday, January 30, 2008 10:12 AM >>> To: [hidden email] >>> Subject: Recoding multiple variables into one new variable >>> >>> Hi everyone, >>> >>> I have a database in which the data entry staff entered the responses >>> to one question in four different columns. I would like to combine it >>> all into one column. The syntax I have so far is the following: >>> >>> RECODE >>> q3_1a >>> (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . >>> VARIABLE LABELS new3_1 'Clean table or tray'. >>> EXECUTE . >>> >>> >>> SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into >>> new3_1. I don't have to worry about any response overriding another >> one >>> because each response is affiliated with a different person. >>> >>> I am trying to avoid doing frequencies of each and tallying it up the >>> total by hand. Is there a syntax that will allow me to recode multiple >>> variables into one variable? >>> >>> Thanks so much, >>> Deepa >>> >>> ===================== >>> 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 >> > > > -- > GfK BH > Samir Omerovic > > ===================== > 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 > > -- GfK BH Samir Omerovic ===================== 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 |
|
It will work but only with this particular data structure. It's so much
simpler to not mess with the data and just get the frequencies with multiple response, don't you think? -----Original Message----- From: [hidden email] [mailto:[hidden email]] Sent: Wednesday, January 30, 2008 11:22 AM To: ViAnn Beadle Cc: [hidden email]; [hidden email] Subject: RE: Recoding multiple variables into one new variable This actually works since I have been doing it for a long time. Just try it. it works since the answers are not multiple answers. if the file is structered like this v1 v2 v3 1 2 3 3 4 5 it works. > This will definitely not work. > > You have two choices with tabulating multiple response variables--use a > procedure that understands them or use VARSTOCASES to restructure the file > so that each response becomes a new case (total overkill as an approach). > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > [Samir Omeroviæ] > Sent: Wednesday, January 30, 2008 9:54 AM > To: [hidden email] > Subject: Re: Recoding multiple variables into one new variable > > Hi there, > > there is simpler solution to recode > > RECODE > q3_1a q3_1b q3_1c > (1=1) (2=2) (99=99) INTO new3_1 new3_1 new3_1 . > execute. > > and also there is SUM > > Compute new3_1=SUM(q3_1a,q3_1b,q3_1c). > execute. > > Of course both methods assume there is only one value in each row so it is > not actual multiple answer. > > BR > Samir > > > >> Deepa, >> >> I don't know if this is the best method, but you can do that by using a >> different RECODE command for each of the original variables (tested in >> v.16): >> >> RECODE >> q3_1a >> (1=1) (2=2) (99=99) INTO new3_1 . >> RECODE >> q3_1b >> (1=1) (2=2) (99=99) INTO new3_1 . >> RECODE >> q3_1c >> (1=1) (2=2) (99=99) INTO new3_1 . >> RECODE >> q3_1d >> (1=1) (2=2) (99=99) INTO new3_1 . >> VARIABLE LABELS new3_1 'Clean table or tray'. >> EXECUTE . >> >> >> A couple of points to remember: >> 1. This will only work if you don't have rows with data in more than one >> column. If you do, then the latter variable will overwrite the previous >> one. >> 2. I haven't included the SYSMIS values in the code. I've done this >> because I'm assuming that if the first row might have "2" for q3_1a but >> have SYSMIS for all the other three vars. If that is true, then the >> code will overwrite "2" with SYSMIS in new3_1. >> >> HTH. >> >> >> Shahrukh >> >> >> >> >> >>> -----Original Message----- >>> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf >> Of >>> Deepa Bhat >>> Sent: Wednesday, January 30, 2008 10:12 AM >>> To: [hidden email] >>> Subject: Recoding multiple variables into one new variable >>> >>> Hi everyone, >>> >>> I have a database in which the data entry staff entered the responses >>> to one question in four different columns. I would like to combine it >>> all into one column. The syntax I have so far is the following: >>> >>> RECODE >>> q3_1a >>> (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . >>> VARIABLE LABELS new3_1 'Clean table or tray'. >>> EXECUTE . >>> >>> >>> SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into >>> new3_1. I don't have to worry about any response overriding another >> one >>> because each response is affiliated with a different person. >>> >>> I am trying to avoid doing frequencies of each and tallying it up the >>> total by hand. Is there a syntax that will allow me to recode multiple >>> variables into one variable? >>> >>> Thanks so much, >>> Deepa >>> >>> ===================== >>> 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 >> > > > -- > GfK BH > Samir Omerovic > > ===================== > 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 > > -- GfK BH Samir Omerovic ===================== 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 ViAnn Beadle
ViAnn,
The code does work based on the dataset that Deepa mentioned. I did put the caveat in my previous post that the code would work only if each row contains a valid value for just one of the four variables. In that sense, the purpose of the code was (kinda sorta) similar to what Gene suggested with the COMPUTE command. I realize that there are limitations to the code in what kind of dataset it will work for (something you touched on in your reply to Samir). Nonetheless, it should work for what was suggested and new3_1 will not be set as the last recode executed. - Shahrukh > -----Original Message----- > From: ViAnn Beadle [mailto:[hidden email]] > Sent: Wednesday, January 30, 2008 11:11 AM > To: Hashmi, Syed S > Cc: [hidden email] > Subject: RE: Recoding multiple variables into one new variable > > This definitely will not work. What will happen is that new3_1 will be set > to that last recode executed. > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Hashmi, Syed S > Sent: Wednesday, January 30, 2008 9:56 AM > To: [hidden email] > Subject: Re: Recoding multiple variables into one new variable > > Deepa, > > I don't know if this is the best method, but you can do that by using a > different RECODE command for each of the original variables (tested in > v.16): > > RECODE > q3_1a > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1b > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1c > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1d > (1=1) (2=2) (99=99) INTO new3_1 . > VARIABLE LABELS new3_1 'Clean table or tray'. > EXECUTE . > > > A couple of points to remember: > 1. This will only work if you don't have rows with data in more than > column. If you do, then the latter variable will overwrite the previous > one. > 2. I haven't included the SYSMIS values in the code. I've done this > because I'm assuming that if the first row might have "2" for q3_1a but > have SYSMIS for all the other three vars. If that is true, then the > code will overwrite "2" with SYSMIS in new3_1. > > HTH. > > > Shahrukh > > > > > > > -----Original Message----- > > From: SPSSX(r) Discussion [mailto:[hidden email]] On > Of > > Deepa Bhat > > Sent: Wednesday, January 30, 2008 10:12 AM > > To: [hidden email] > > Subject: Recoding multiple variables into one new variable > > > > Hi everyone, > > > > I have a database in which the data entry staff entered the responses > > to one question in four different columns. I would like to combine it > > all into one column. The syntax I have so far is the following: > > > > RECODE > > q3_1a > > (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . > > VARIABLE LABELS new3_1 'Clean table or tray'. > > EXECUTE . > > > > > > SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into > > new3_1. I don't have to worry about any response overriding another > one > > because each response is affiliated with a different person. > > > > I am trying to avoid doing frequencies of each and tallying it up > > total by hand. Is there a syntax that will allow me to recode multiple > > variables into one variable? > > > > Thanks so much, > > Deepa > > > > ===================== > > 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 > 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 |
|
In reply to this post by ViAnn Beadle
At 11:11 AM 1/30/2008, Deepa Bhat wrote:
>I have a database in which the data entry staff entered the >responses to one question in four different columns. I would like to >combine it all into one column. The syntax I have so far is the following: > >RECODE > q3_1a > (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . >VARIABLE LABELS new3_1 'Clean table or tray'. Several workable forms of transformation logic have been posted. Regarding the general problem, at 02:14 PM 1/30/2008, ViAnn Beadle wrote: >[These] will work but only with this particular data structure. It's >so much simpler to not mess with the data and just get the >frequencies with multiple response, don't you think? *De gustibus non disputandum est.* Nevertheless, here's why I would transform the data, in this case: On the description, this isn't a multiple-response answer; it's a single-response answer, that's been represented in an apparent multiple-response format. I'd definitely create a single variable, representing the question and response as presented. Now, when you start with a confusing representation, your transformation of it to a clear representation can be muddled, if you aren't careful. The input form supports a number of logic errors, including recording more than one response. In recoding, it's crucial to account for this possibility, which I think none of the proposed solutions do. The posting doesn't make clear how the data are supposed to be represented. The following (not tested) assumes that, . q3_1a, q3_1b, and q3_1c are 2 if and only if the response to question 3 is a, b or c respectively. . q3_1a, q3_1b, and q3_1c are 1 if and only if (a) the question was answered, and (b) the answer is *not* that represented by the specific variable . q3_1a, q3_1b, and q3_1c are all 99, or all system-missing, if the question wasn't answered. Assuming this, something like the following. It's not tested. I'm sure it could be made more compact. Note use of 'VALUE' function, to make code independent of user-missing values that may be specified for the input variables. And observe that real error-checking code can be the finickiest code there is. NUMERIC new3_1 (F2). VAR LABEL new3_1 'Response to q.3, condensed'. VAL LABEL new3_1 1 'a' 2 'b' 3 'c' 99 'No resp' 100 '(Sys.Msg)' 94 'ERR: Logc' /* Error in the logic, below 95 'ERR: code' /* Any value but 1,2,99,sysmis 96 'ERR: ?Msg' /* Inconsistent indication of missing 97 'ERR: 0rsp' /* No response, but not given as missing 98 'ERR:>1rsp' /* More than one response given */. MISSING VALUES new3_1 (94,100). COMPUTE #N_99 = 0. COMPUTE #N_Sysm = 0. COMPUTE #N_BadC = 0. COMPUTE #N_Logc = 0. DO REPEAT Resp_Var = q3_1a q3_1b q3_1c /Resp_Val = 1 2 3. * The following is to catch any DO IF that is . * skipped because a clause tests 'missing': . . COMPUTE #N_Logc = #N_Logc + 1. . DO IF SYSMIS(Resp_Var). . COMPUTE #N_Logc = #N_Logc - 1 /* Caught it */. . COMPUTE #N_Sysm = #N_Sysm + 1. . ELSE IF VALUE(Resp_Var) EQ 99. . COMPUTE #N_Logc = #N_Logc - 1 /* Caught it */. . COMPUTE #N_99 = #N_99 + 1. . ELSE IF VALUE(Resp_Var) EQ 1. . COMPUTE #N_Logc = #N_Logc - 1 /* Caught it */. * (Do nothing else, for 'not chosen' response). . ELSE IF VALUE(Resp_Var) EQ 2. . COMPUTE #N_Logc = #N_Logc - 1 /* Caught it */. . DO IF SYSMIS(new3_1). . COMPUTE new3_1 = Resp_Val. . ELSE. . COMPUTE new3_1 = 98. . END IF. . ELSE. . COMPUTE #N_Logc = #N_Logc - 1 /* Caught it */. . COMPUTE #N_Badc = #N_Badc + 1. . END IF. END REPEAT. DO IF #N_Logc GT 0 /* Program logic error */. . COMPUTE new3_1 = 94 . ELSE IF #N_Badc GT 0 /* Bad value in input vbl */. . COMPUTE new3_1 = 95 . ELSE IF NOT ANY (#N_Sysm,0,3)/* Inconsistency: SYSMIS */. . COMPUTE new3_1 = 96 . ELSE IF NOT ANY (#N_99,0,3) /* Inconsistency: '99' val*/. . COMPUTE new3_1 = 96 . ELSE IF VALUE(new3_1) EQ 98. /* More than one '2' value*/. . COMPUTE new3_1 = 98 . ELSE IF #N_Sysm EQ 3 /* OK: all system-missing */. . COMPUTE new3_1 =100 . ELSE IF #N_99 EQ 3 /* OK: all '99' */. . COMPUTE new3_1 = 99 . ELSE IF SYSMIS (new3_1) /* No '2' value found */. . COMPUTE new3_1 = 96 . ELSE IF ANY(new3_1,1,2,3) /* Valid response */. END IF. FREQUENCIES new3_1. ===================== 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 Hashmi, Syed S
I never trust assumptions about data until proven. Better to be safe than
sorry. Also, I think that transformations like this are just a hassle when the OP wanted frequency counts against the set. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Hashmi, Syed S Sent: Wednesday, January 30, 2008 2:09 PM To: [hidden email] Subject: Re: Recoding multiple variables into one new variable ViAnn, The code does work based on the dataset that Deepa mentioned. I did put the caveat in my previous post that the code would work only if each row contains a valid value for just one of the four variables. In that sense, the purpose of the code was (kinda sorta) similar to what Gene suggested with the COMPUTE command. I realize that there are limitations to the code in what kind of dataset it will work for (something you touched on in your reply to Samir). Nonetheless, it should work for what was suggested and new3_1 will not be set as the last recode executed. - Shahrukh > -----Original Message----- > From: ViAnn Beadle [mailto:[hidden email]] > Sent: Wednesday, January 30, 2008 11:11 AM > To: Hashmi, Syed S > Cc: [hidden email] > Subject: RE: Recoding multiple variables into one new variable > > This definitely will not work. What will happen is that new3_1 will be set > to that last recode executed. > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Hashmi, Syed S > Sent: Wednesday, January 30, 2008 9:56 AM > To: [hidden email] > Subject: Re: Recoding multiple variables into one new variable > > Deepa, > > I don't know if this is the best method, but you can do that by using a > different RECODE command for each of the original variables (tested in > v.16): > > RECODE > q3_1a > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1b > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1c > (1=1) (2=2) (99=99) INTO new3_1 . > RECODE > q3_1d > (1=1) (2=2) (99=99) INTO new3_1 . > VARIABLE LABELS new3_1 'Clean table or tray'. > EXECUTE . > > > A couple of points to remember: > 1. This will only work if you don't have rows with data in more than > column. If you do, then the latter variable will overwrite the previous > one. > 2. I haven't included the SYSMIS values in the code. I've done this > because I'm assuming that if the first row might have "2" for q3_1a but > have SYSMIS for all the other three vars. If that is true, then the > code will overwrite "2" with SYSMIS in new3_1. > > HTH. > > > Shahrukh > > > > > > > -----Original Message----- > > From: SPSSX(r) Discussion [mailto:[hidden email]] On > Of > > Deepa Bhat > > Sent: Wednesday, January 30, 2008 10:12 AM > > To: [hidden email] > > Subject: Recoding multiple variables into one new variable > > > > Hi everyone, > > > > I have a database in which the data entry staff entered the responses > > to one question in four different columns. I would like to combine it > > all into one column. The syntax I have so far is the following: > > > > RECODE > > q3_1a > > (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . > > VARIABLE LABELS new3_1 'Clean table or tray'. > > EXECUTE . > > > > > > SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into > > new3_1. I don't have to worry about any response overriding another > one > > because each response is affiliated with a different person. > > > > I am trying to avoid doing frequencies of each and tallying it up > > total by hand. Is there a syntax that will allow me to recode multiple > > variables into one variable? > > > > Thanks so much, > > Deepa > > > > ===================== > > 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 > 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 ===================== 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 Deepa Bhat
Thanks everyone for their input.
I tried this output and it works. I have tried it with a few variables and so far when I do frequencies, they match when I do them individually. Thanks again. This is a really great group! Deepa >>> "Hashmi, Syed S" <[hidden email]> 01/30/08 11:55 AM >>> Deepa, I don't know if this is the best method, but you can do that by using a different RECODE command for each of the original variables (tested in v.16): RECODE q3_1a (1=1) (2=2) (99=99) INTO new3_1 . RECODE q3_1b (1=1) (2=2) (99=99) INTO new3_1 . RECODE q3_1c (1=1) (2=2) (99=99) INTO new3_1 . RECODE q3_1d (1=1) (2=2) (99=99) INTO new3_1 . VARIABLE LABELS new3_1 'Clean table or tray'. EXECUTE . A couple of points to remember: 1. This will only work if you don't have rows with data in more than one column. If you do, then the latter variable will overwrite the previous one. 2. I haven't included the SYSMIS values in the code. I've done this because I'm assuming that if the first row might have "2" for q3_1a but have SYSMIS for all the other three vars. If that is true, then the code will overwrite "2" with SYSMIS in new3_1. HTH. Shahrukh > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Deepa Bhat > Sent: Wednesday, January 30, 2008 10:12 AM > To: [hidden email] > Subject: Recoding multiple variables into one new variable > > Hi everyone, > > I have a database in which the data entry staff entered the responses > to one question in four different columns. I would like to combine it > all into one column. The syntax I have so far is the following: > > RECODE > q3_1a > (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . > VARIABLE LABELS new3_1 'Clean table or tray'. > EXECUTE . > > > SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into > new3_1. I don't have to worry about any response overriding another > because each response is affiliated with a different person. > > I am trying to avoid doing frequencies of each and tallying it up the > total by hand. Is there a syntax that will allow me to recode multiple > variables into one variable? > > Thanks so much, > Deepa > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except > 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 |
|
In reply to this post by Deepa Bhat
I would suggest one possible change to Steve's option:
COMPUTE new3_1=MAX(q3_1a,q3_1b,q3_1c,q3_1d). That is the addition of .1 which would require only one valid response to any of the 4 variables--the rest could be missing. Of course this only works correctly if the assumption of only one response per case is true. COMPUTE new3_1=MAX.1(q3_1a,q3_1b,q3_1c,q3_1d). Melissa -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Steve Runfeldt Sent: Thursday, January 31, 2008 8:56 AM To: [hidden email] Subject: [SPSSX-L] Recoding multiple variables into one new variable Importance: Low Date: Wed, 30 Jan 2008 11:11:55 -0500 From: Deepa Bhat <[hidden email]> Subject: Recoding multiple variables into one new variable Hi everyone, I have a database in which the data entry staff entered the responses to one question in four different columns. I would like to combine it all into one column. The syntax I have so far is the following: RECODE q3_1a (1=1) (2=2) (99=99) (SYSMIS=SYSMIS) INTO new3_1 . VARIABLE LABELS new3_1 'Clean table or tray'. EXECUTE . SPSS won't let me recode another variable (q3_1b q3_1c q3_1d) into new3_1. I don't have to worry about any response overriding another one because each response is affiliated with a different person. I am trying to avoid doing frequencies of each and tallying it up the total by hand. Is there a syntax that will allow me to recode multiple variables into one variable? Thanks so much, Deepa ************************************************************* Deepa, I believe that another solution might be the following: COMPUTE new3_1=MAX(q3_1a,q3_1b,q3_1c,q3_1d). This should take the highest value for each case and put it into the new var. It should skip the system missing cases. If you are using 9s or 99s to indicate missing values, you may need to recode these in the original variables to either sysmis or 0 first. This is what I would have done. I agree with ViAnn, that, if all you want is simple frequencies, then Tables or CTables is your best bet. But I have rarely just wanted frequency counts of data. Most of the time descriptive stats are just a prelude to something more sophisticated. If you are going to do anything with that data, you are going to want them all consolidated. Steve ===================== 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 PRIVILEGED AND CONFIDENTIAL INFORMATION This transmittal and any attachments may contain PRIVILEGED AND CONFIDENTIAL information and is intended only for the use of the addressee. If you are not the designated recipient, or an employee or agent authorized to deliver such transmittals to the designated recipient, you are hereby notified that any dissemination, copying or publication of this transmittal is strictly prohibited. If you have received this transmittal in error, please notify us immediately by replying to the sender and delete this copy from your system. You may also call us at (309) 827-6026 for assistance. ===================== 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 |
