Dear SPSSX list,
Can anyone recommend a straightforward way to count the number of times a test has been taken, separately for each testing session? For example, suppose that three tests have been administered once a year (TEST1,TEST2,TEST3), but sometimes people don't show up (.). I want to create three additional variables that record the number of times each person has taken each test (TAKEN1,TAKEN2,TAKEN3). PERSON TEST1 TEST2 TEST2 TAKEN1 TAKEN2 TAKEN3 1 50 45 48 1 2 3 2 . 51 53 . 1 2 3 . . 41 . . 1 4 56 47 . 1 2 . 5 55 . . 1 . . Any suggestions would be appreciated greatly. Gareth ===================== 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 |
Gareth, try this syntax:
compute #aux = 0. do repeat x = test1 to test3 / y = taken1 to taken3. + do if not missing(x) . + compute #aux = #aux + 1. + compute y = #aux. + end if. end repeat. form taken1 to taken3 (f2). execute. Best, Jan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gareth Sent: Wednesday, August 24, 2011 3:11 PM To: [hidden email] Subject: Counting test administrations Dear SPSSX list, Can anyone recommend a straightforward way to count the number of times a test has been taken, separately for each testing session? For example, suppose that three tests have been administered once a year (TEST1,TEST2,TEST3), but sometimes people don't show up (.). I want to create three additional variables that record the number of times each person has taken each test (TAKEN1,TAKEN2,TAKEN3). PERSON TEST1 TEST2 TEST2 TAKEN1 TAKEN2 TAKEN3 1 50 45 48 1 2 3 2 . 51 53 . 1 2 3 . . 41 . . 1 4 56 47 . 1 2 . 5 55 . . 1 . . Any suggestions would be appreciated greatly. Gareth ===================== 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 _____________ Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem. Jste si jisti, že opravdu potřebujete vytisknout tuto zprávu a/nebo její přílohy? Myslete na přírodu. This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission. Are you sure that you really need a print version of this message and/or its attachments? Think about nature. -.- -- ===================== 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 |
Administrator
|
In reply to this post by rmjdgeh
VECTOR Taken(3).
DO REPEAT Test=TEST1 TO TEST3 /INDEX=1 TO 3. COMPUTE TAKEN(INDEX)=NVALID(TEST). IF (INDEX GT 1) TAKEN(INDEX)=SUM(TAKEN(INDEX),TAKEN(INDEX-1)). END REPEAT. RECODE Taken1 TO Taken3 (0=SYSMIS). --
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?" |
In reply to this post by rmjdgeh
David, I suspect that your code does not give the desired output - see Person 4 and Person 5.
Best regards, Jan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: Wednesday, August 24, 2011 3:59 PM To: [hidden email] Subject: Re: Counting test administrations VECTOR Taken(3). DO REPEAT Test=TEST1 TO TEST3 /INDEX=1 TO 3. COMPUTE TAKEN(INDEX)=NVALID(TEST). IF (INDEX GT 1) TAKEN(INDEX)=SUM(TAKEN(INDEX),TAKEN(INDEX-1)). END REPEAT. RECODE TEST1 TO TEST3 (0=SYSMIS). -- rmjdgeh wrote: > > Dear SPSSX list, > > Can anyone recommend a straightforward way to count the number of > times a test has been taken, separately for each testing session? For > example, suppose that three tests have been administered once a year > (TEST1,TEST2,TEST3), but sometimes people don't show up (.). > > I want to create three additional variables that record the number of > times each person has taken each test (TAKEN1,TAKEN2,TAKEN3). > > PERSON TEST1 TEST2 TEST2 TAKEN1 TAKEN2 TAKEN3 > 1 50 45 48 1 2 3 > 2 . 51 53 . 1 2 > 3 . . 41 . . 1 > 4 56 47 . 1 2 . > 5 55 . . 1 . . > > Any suggestions would be appreciated greatly. > > Gareth > > ===================== > 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 > -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Counting-test-administrations-tp4730397p4730538.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 _____________ Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem. Jste si jisti, že opravdu potřebujete vytisknout tuto zprávu a/nebo její přílohy? Myslete na přírodu. This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission. Are you sure that you really need a print version of this message and/or its attachments? Think about nature. -.- -- ===================== 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 |
Administrator
|
Jan,
Upon further reflection, I suspect you are correct ;-( My bad. I usually test my code before posting. Apologies for that one . David
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?" |
In reply to this post by David Marso
Hi Gareth
If I've understood properly your question you're trying to find out the number of times a test has been taken and a straightforward, so a way to find out should be to run a simple frequency for each test. Otherwise, If want you want is to find out how many tests has each person taken you could use the following syntax. Hope it helps! compute count=0. if (test1>0) count=1. if (test2>0) count=count+1. if (test3>0) count=count+1. compute taken1=0. compute taken2=0. compute taken3=0. if (count=1)taken1=1. if (count=2)taken2=1. if (count=3)taken3=1. execute. Thanks! Joan Casellas Vega Media Research Analyst Phone: +44 20 7593 1585 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: 24 August 2011 15:00 To: [hidden email] Subject: Re: Counting test administrations VECTOR Taken(3). DO REPEAT Test=TEST1 TO TEST3 /INDEX=1 TO 3. COMPUTE TAKEN(INDEX)=NVALID(TEST). IF (INDEX GT 1) TAKEN(INDEX)=SUM(TAKEN(INDEX),TAKEN(INDEX-1)). END REPEAT. RECODE Taken1 TO Taken3 (0=SYSMIS). -- rmjdgeh wrote: > > Dear SPSSX list, > > Can anyone recommend a straightforward way to count the number of times a > test has been taken, c? For example, > suppose that three tests have been administered once a year > (TEST1,TEST2,TEST3), but sometimes people don't show up (.). > > I want to create three additional variables that record the number of > times > each person has taken each test (TAKEN1,TAKEN2,TAKEN3). > > PERSON TEST1 TEST2 TEST2 TAKEN1 TAKEN2 TAKEN3 > 1 50 45 48 1 2 3 > 2 . 51 53 . 1 2 > 3 . . 41 . . 1 > 4 56 47 . 1 2 . > 5 55 . . 1 . . > > Any suggestions would be appreciated greatly. > > Gareth > > ===================== > 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 > -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Counting-test-administrations- tp4730397p4730544.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 David Marso
Hi Gareth,
Having second thoughts, the following syntax will count the number of times a test has been taken, separately for each testing session: If (nvalid(test1)>0) taken1=1. If (nvalid(test2)>0) taken2=1. If (nvalid(test3)>0) taken3=1. Cheers, Joan Joan Casellas Vega Media Research Analyst Phone: +44 20 7593 1585 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: 24 August 2011 15:00 To: [hidden email] Subject: Re: Counting test administrations VECTOR Taken(3). DO REPEAT Test=TEST1 TO TEST3 /INDEX=1 TO 3. COMPUTE TAKEN(INDEX)=NVALID(TEST). IF (INDEX GT 1) TAKEN(INDEX)=SUM(TAKEN(INDEX),TAKEN(INDEX-1)). END REPEAT. RECODE Taken1 TO Taken3 (0=SYSMIS). -- rmjdgeh wrote: > > Dear SPSSX list, > > Can anyone recommend a straightforward way to count the number of times a > test has been taken, separately for each testing session? For example, > suppose that three tests have been administered once a year > (TEST1,TEST2,TEST3), but sometimes people don't show up (.). > > I want to create three additional variables that record the number of > times > each person has taken each test (TAKEN1,TAKEN2,TAKEN3). > > PERSON TEST1 TEST2 TEST2 TAKEN1 TAKEN2 TAKEN3 > 1 50 45 48 1 2 3 > 2 . 51 53 . 1 2 > 3 . . 41 . . 1 > 4 56 47 . 1 2 . > 5 55 . . 1 . . > > Any suggestions would be appreciated greatly. > > Gareth > > ===================== > 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 > -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Counting-test-administrations- tp4730397p4730544.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 |