|
Hello,
I've got a list of variables which contain strings and numerics, and I'd like to convert them all to numerics using a combination of vectors and loops. I've discovered that a vector must either contain all strings or all numerics, so I've tried to embed a vector command in a loop, but it's not working at all. Is anyone able to help me? It would be greatly appreciated. All my variables are listed v1 to v180, and are in sets of five of which the middle three are always string, and the outside 2 are numeric. e.g. v1 to v10 are assigned the values: 11,a,r,r,10, 4,s,g,f,23 And I was going to recode them into a new variable list called va1 to va180. I defined this earlier, by zeroing it simply: DO REPEAT va=va1 TO va180. compute va =0. END REPEAT. Here's my current syntax: LOOP #cnt = 1 to 177 BY 5. VECTOR v=v(cnt) TO v(cnt+2). VECTOR va = va(cnt) TO va(cnt+2). RECODE v(cnt) (CONVERT) ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) ('S'=6) ('D'=7) ('C'=8) INTO va(cnt). RECODE v(cnt+1) (CONVERT) ('r'=1) ('g'=2) ('b'=3) ('y'=4) INTO va(cnt +1). RECODE v(cnt+2) (CONVERT) ('r'=1) ('f'=2) INTO va(cnt +2). END LOOP. EXECUTE. Thanks! Russell ===================== 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 |
|
See if something like this untested syntax does what you want.
numeric va1 to va180(f3). do repeat v = v1 to v180/va = va1 to va180 /i = 1 to 180. compute position = mod(i,5). do if position eq 1 or position eq 0. RECODE v (CONVERT) ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) ('S'=6)('D'=7) ('C'=8) INTO va. else if position eq 2. RECODE v (CONVERT) ('r'=1) ('g'=2) ('b'=3) ('y'=4) INTO va. Else if position eq 3. RECODE (CONVERT) ('r'=1) ('f'=2) INTO va. else if postion eq 4. * what to do here?. else. print /position ' should not be here'. end if. Art Kendall Social Research Consultants Russell Deighton wrote: > Hello, > > I've got a list of variables which contain strings and numerics, and I'd > like to convert them all to numerics using a combination of vectors and > loops. I've discovered that a vector must either contain all strings or > all numerics, so I've tried to embed a vector command in a loop, but it's > not working at all. Is anyone able to help me? It would be greatly > appreciated. > > All my variables are listed v1 to v180, and are in sets of five of which > the middle three are always string, and the outside 2 are numeric. > > e.g. > v1 to v10 are assigned the values: > 11,a,r,r,10, 4,s,g,f,23 > > > And I was going to recode them into a new variable list called va1 to > va180. I defined this earlier, by zeroing it simply: > > DO REPEAT va=va1 TO va180. > compute va =0. > END REPEAT. > > > Here's my current syntax: > > LOOP #cnt = 1 to 177 BY 5. > VECTOR v=v(cnt) TO v(cnt+2). > VECTOR va = va(cnt) TO va(cnt+2). > RECODE v(cnt) (CONVERT) ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) ('S'=6) > ('D'=7) ('C'=8) INTO va(cnt). > RECODE v(cnt+1) (CONVERT) ('r'=1) ('g'=2) ('b'=3) ('y'=4) INTO va(cnt +1). > RECODE v(cnt+2) (CONVERT) ('r'=1) ('f'=2) INTO va(cnt +2). > END LOOP. > EXECUTE. > > Thanks! > Russell > > ===================== > 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 |
|
As I look at your post again I see that I probably have the wrong recode
under the specific condition. for Position values of 1 and 0 compute va=v. check which recode you want for 2, 3, and 4. Also you will have to define missing values value labels and variable labels. Art Kendall Social Research Consultants Art Kendall wrote: > See if something like this untested syntax does what you want. > > numeric va1 to va180(f3). > do repeat v = v1 to v180/va = va1 to va180 /i = 1 to 180. > compute position = mod(i,5). > do if position eq 1 or position eq 0. > RECODE v (CONVERT) ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) > ('S'=6)('D'=7) ('C'=8) INTO va. > else if position eq 2. > RECODE v (CONVERT) ('r'=1) ('g'=2) ('b'=3) ('y'=4) INTO va. > Else if position eq 3. > RECODE (CONVERT) ('r'=1) ('f'=2) INTO va. > else if postion eq 4. > * what to do here?. > else. > print /position ' should not be here'. > end if. > > > > Art Kendall > Social Research Consultants > > Russell Deighton wrote: >> Hello, >> >> I've got a list of variables which contain strings and numerics, and I'd >> like to convert them all to numerics using a combination of vectors and >> loops. I've discovered that a vector must either contain all strings or >> all numerics, so I've tried to embed a vector command in a loop, but >> it's >> not working at all. Is anyone able to help me? It would be greatly >> appreciated. >> >> All my variables are listed v1 to v180, and are in sets of five of which >> the middle three are always string, and the outside 2 are numeric. >> >> e.g. >> v1 to v10 are assigned the values: >> 11,a,r,r,10, 4,s,g,f,23 >> >> >> And I was going to recode them into a new variable list called va1 to >> va180. I defined this earlier, by zeroing it simply: >> >> DO REPEAT va=va1 TO va180. >> compute va =0. >> END REPEAT. >> >> >> Here's my current syntax: >> >> LOOP #cnt = 1 to 177 BY 5. >> VECTOR v=v(cnt) TO v(cnt+2). >> VECTOR va = va(cnt) TO va(cnt+2). >> RECODE v(cnt) (CONVERT) ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) ('S'=6) >> ('D'=7) ('C'=8) INTO va(cnt). >> RECODE v(cnt+1) (CONVERT) ('r'=1) ('g'=2) ('b'=3) ('y'=4) INTO va(cnt >> +1). >> RECODE v(cnt+2) (CONVERT) ('r'=1) ('f'=2) INTO va(cnt +2). >> END LOOP. >> EXECUTE. >> >> Thanks! >> Russell >> >> ===================== >> 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 > > ===================== 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 Art Kendall
Dear Art,
After a few changes, the syntax seems to work perfectly, but I'm still getting all kinds of error messages (pasted in below). Any idea why? Russell GET FILE='C:\Documents and Settings\amplontz\Desktop\Russ SPSS\test data.sav'. DATASET NAME DataSet1 WINDOW=FRONT. GET FILE='C:\Documents and Settings\amplontz\Desktop\Russ SPSS\test.sav'. DATASET NAME DataSet2 WINDOW=FRONT. DATASET ACTIVATE DataSet2. DATASET CLOSE DataSet1. numeric va1 to va180(f3). do repeat v = v3 to v182 /va = va1 to va180 /i = 1 to 180. compute position = mod(i,5). do if position eq 1 or position eq 0. compute va=v. else if position eq 2. RECODE v (CONVERT) ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) ('S'=6)('D'=7) ('C'=8) INTO va. else if position eq 3. RECODE v (CONVERT) ('r'=1) ('g'=2) ('b'=3) ('y'=4) INTO va. Else if position eq 4. RECODE v (CONVERT) ('r'=1) ('f'=2) INTO va. else. print /position ' should not be here'. end if. END REPEAT. >Error # 4657 in column 11. Text: CONVERT >The RECODE command attempts to use the keyword CONVERT in connection with a >numeric variable. >This command not executed. >Error # 4657 in column 11. Text: CONVERT >The RECODE command attempts to use the keyword CONVERT in connection with a >numeric variable. >This command not executed. >Error # 4657 in column 11. Text: CONVERT >The RECODE command attempts to use the keyword CONVERT in connection with a >numeric variable. >This command not executed. >Error # 4309 in column 256. Text: (End of Command) >Invalid combination of data types in an assignment. Character strings may >only be assigned to string variables. Numeric and logical quantities may >only be assigned to numeric variables. Consider using the STRING or NUMBER >function. >This command not executed. >Error # 4309 in column 256. Text: (End of Command) >Invalid combination of data types in an assignment. Character strings may >only be assigned to string variables. Numeric and logical quantities may >only be assigned to numeric variables. Consider using the STRING or NUMBER >function. >This command not executed. -----Original Message----- From: Art Kendall [mailto:[hidden email]] Sent: Sun 05/10/2008 23:29 To: Russell Deighton Cc: [hidden email] Subject: Re: loops and vectors See if something like this untested syntax does what you want. numeric va1 to va180(f3). do repeat v = v1 to v180/va = va1 to va180 /i = 1 to 180. compute position = mod(i,5). do if position eq 1 or position eq 0. RECODE v (CONVERT) ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) ('S'=6)('D'=7) ('C'=8) INTO va. else if position eq 2. RECODE v (CONVERT) ('r'=1) ('g'=2) ('b'=3) ('y'=4) INTO va. Else if position eq 3. RECODE (CONVERT) ('r'=1) ('f'=2) INTO va. else if postion eq 4. * what to do here?. else. print /position ' should not be here'. end if. Art Kendall Social Research Consultants Russell Deighton wrote: > Hello, > > I've got a list of variables which contain strings and numerics, and I'd > like to convert them all to numerics using a combination of vectors and > loops. I've discovered that a vector must either contain all strings or > all numerics, so I've tried to embed a vector command in a loop, but it's > not working at all. Is anyone able to help me? It would be greatly > appreciated. > > All my variables are listed v1 to v180, and are in sets of five of which > the middle three are always string, and the outside 2 are numeric. > > e.g. > v1 to v10 are assigned the values: > 11,a,r,r,10, 4,s,g,f,23 > > > And I was going to recode them into a new variable list called va1 to > va180. I defined this earlier, by zeroing it simply: > > DO REPEAT va=va1 TO va180. > compute va =0. > END REPEAT. > > > Here's my current syntax: > > LOOP #cnt = 1 to 177 BY 5. > VECTOR v=v(cnt) TO v(cnt+2). > VECTOR va = va(cnt) TO va(cnt+2). > RECODE v(cnt) (CONVERT) ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) ('S'=6) > ('D'=7) ('C'=8) INTO va(cnt). > RECODE v(cnt+1) (CONVERT) ('r'=1) ('g'=2) ('b'=3) ('y'=4) INTO va(cnt +1). > RECODE v(cnt+2) (CONVERT) ('r'=1) ('f'=2) INTO va(cnt +2). > END LOOP. > EXECUTE. > > Thanks! > Russell > > ===================== > 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. Version: 7.5.524 / Virus Database: 270.7.6/1709 - Release Date: 5/10/2008 9:20 AM ====================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 Art Kendall
see if this get you closer.
BTW for the string variables that have characters such as 'H' are there numeric characters in those variables? CONVERT would only be used for that situation. you could supply additional specifications to recode those values. ('1'=1) etc Also some of your input specifications are uppercase and some are lower. If they are mixed cases within a variable, you should provide more specifications ('r','R'=1)etc. numeric va3 to va182(f3). do repeat v = v3 to v182 /va = va3 to va182 /i = 3 to 182. compute position = mod(i,5). do if position eq 0. RECODE v (else=copy)INTO va. else if position eq 1. RECODE v ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) ('S'=6)('D'=7) ('C'=8)(missing=-3)(sysmis=-2) (else= -1)INTO va. else if position eq 2. RECODE v ('r'=1) ('g'=2) ('b'=3) ('y'=4)(missing=-3)(sysmis=-2) (else= -1) INTO va. Else if position eq 3. RECODE ('r'=1) ('f'=2)(missing=-3)(sysmis=-2)(else=-1) INTO va. else if position eq 4. RECODE v INTO va. else. print /position ' should not be here'. end if. END REPEAT. missing values va3 to va182 (lo thru -1). value labels -1 'no specification provided for RECODE' -2 'input as system missing' -3 'had a user missing values distinctions lost'. Art Kendall Social Research Consultants Russell Deighton wrote: > Dear Art, > > Thanks so much for that lovely syntax (much more elegant than mine I'm afraid). It's still causing errors for reasons I don't understand. I've changed 3 things: > 1. v actually goes from v3 to v182, so I've made a corresponding change in the DO REPEAT > 2. added some transformations for positions 0, and 4 > 3. added an END REPEAT at the end > > The syntax and the first few errors are included below. If you had any ideas, I'd be much obliged. > > Russell > > numeric va1 to va180(f3). > do repeat v = v3 to v182 /va = va1 to va180 /i = 1 to 180. > compute position = mod(i,5). > do if position eq 0. > RECODE v INTO va. > else if position eq 1. > RECODE v (CONVERT) ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) > ('S'=6)('D'=7) ('C'=8) INTO va. > else if position eq 2. > RECODE v (CONVERT) ('r'=1) ('g'=2) ('b'=3) ('y'=4) INTO va. > Else if position eq 3. > RECODE (CONVERT) ('r'=1) ('f'=2) INTO va. > else if postion eq 4. > RECODE v INTO va. > else. > print /position ' should not be here'. > end if. > END REPEAT. > > > >> Error # 4631 in column 10. Text: INTO >> On the RECODE command, the list of variables to be recoded includes the >> name of a nonexistent variable. >> This command not executed. >> > > >> Error # 4657 in column 11. Text: CONVERT >> The RECODE command attempts to use the keyword CONVERT in connection with a >> numeric variable. >> This command not executed. >> > > >> Error # 4657 in column 11. Text: CONVERT >> The RECODE command attempts to use the keyword CONVERT in connection with a >> numeric variable. >> This command not executed. >> > > > > -----Original Message----- > From: Art Kendall [mailto:[hidden email]] > Sent: Sunday, 5 October 2008 11:30 PM > To: Russell Deighton > Cc: [hidden email] > Subject: Re: loops and vectors > > See if something like this untested syntax does what you want. > > numeric va1 to va180(f3). > do repeat v = v1 to v180/va = va1 to va180 /i = 1 to 180. > compute position = mod(i,5). > do if position eq 1 or position eq 0. > RECODE v (CONVERT) ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) > ('S'=6)('D'=7) ('C'=8) INTO va. > else if position eq 2. > RECODE v (CONVERT) ('r'=1) ('g'=2) ('b'=3) ('y'=4) INTO va. > Else if position eq 3. > RECODE (CONVERT) ('r'=1) ('f'=2) INTO va. > else if postion eq 4. > * what to do here?. > else. > print /position ' should not be here'. > end if. > > > > Art Kendall > Social Research Consultants > > Russell Deighton wrote: > >> Hello, >> >> I've got a list of variables which contain strings and numerics, and I'd >> like to convert them all to numerics using a combination of vectors and >> loops. I've discovered that a vector must either contain all strings or >> all numerics, so I've tried to embed a vector command in a loop, but it's >> not working at all. Is anyone able to help me? It would be greatly >> appreciated. >> >> All my variables are listed v1 to v180, and are in sets of five of which >> the middle three are always string, and the outside 2 are numeric. >> >> e.g. >> v1 to v10 are assigned the values: >> 11,a,r,r,10, 4,s,g,f,23 >> >> >> And I was going to recode them into a new variable list called va1 to >> va180. I defined this earlier, by zeroing it simply: >> >> DO REPEAT va=va1 TO va180. >> compute va =0. >> END REPEAT. >> >> >> Here's my current syntax: >> >> LOOP #cnt = 1 to 177 BY 5. >> VECTOR v=v(cnt) TO v(cnt+2). >> VECTOR va = va(cnt) TO va(cnt+2). >> RECODE v(cnt) (CONVERT) ('N'=1) ('U'=2) ('H'=3) ('A'=4) ('F'=5) ('S'=6) >> ('D'=7) ('C'=8) INTO va(cnt). >> RECODE v(cnt+1) (CONVERT) ('r'=1) ('g'=2) ('b'=3) ('y'=4) INTO va(cnt +1). >> RECODE v(cnt+2) (CONVERT) ('r'=1) ('f'=2) INTO va(cnt +2). >> END LOOP. >> EXECUTE. >> >> Thanks! >> Russell >> >> ===================== >> 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. > Version: 7.5.524 / Virus Database: 270.7.6/1709 - Release Date: 5/10/2008 9:20 AM > > > No virus found in this outgoing message. > Checked by AVG. > Version: 7.5.524 / Virus Database: 270.7.6/1709 - Release Date: 5/10/2008 9:20 AM > > > > ===================== 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 Art Kendall
I need to find a way to arrive at an approximate correlation coefficient
given two means, their N's, and sd's I can compute a t value with these data but can't figure out how to covert this to an r or how to arrive at r by another method. Again, I only have the descriptives for each group NOT the raw data. . Any ideas? William N. Dudley, PhD Associate Dean for Research The School of Health and Human Performance Office of Research The University of North Carolina at Greensboro 126 HHP Building, PO Box 26170 Greensboro, NC 27402-6170 VOICE 336.2562475 FAX 336.334.3238 ===================== 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 |
|
If you mean the point biserial correlation for the grouping variable
with the measured variable, then Rsq = F/(F+df). So if you have t., square it to make it F and insert the F in the formula. Paul R. Swank, Ph.D Professor and Director of Research Children's Learning Institute University of Texas Health Science Center Houston, TX 77038 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of William Dudley WNDUDLEY Sent: Tuesday, October 21, 2008 4:09 PM To: [hidden email] Subject: Compute r form group means I need to find a way to arrive at an approximate correlation coefficient given two means, their N's, and sd's I can compute a t value with these data but can't figure out how to covert this to an r or how to arrive at r by another method. Again, I only have the descriptives for each group NOT the raw data. . Any ideas? William N. Dudley, PhD Associate Dean for Research The School of Health and Human Performance Office of Research The University of North Carolina at Greensboro 126 HHP Building, PO Box 26170 Greensboro, NC 27402-6170 VOICE 336.2562475 FAX 336.334.3238 ===================== 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 |
