Hello!
I'm trying to find a way to get a count of unique values across 6 variables: zip 2006 zip2007 zip2008 zip2009 zip2010 zip2011 61477 61477 41365 41365 41365 41365 41365 41365 41365 In the data above, I'd like to add a variable called "count." for the first case, the value of count would be "1" as there is only 1 unique zip in all 6 columns. For the second case, "count" would equal "2" and for the third case, count would equal "1" I'm new to syntax and would appreciate any handholding you could offer with accomplishing this. My heartfelt thanks if you can help! Nancy ===================== 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 |
Try this link -
https://www.ibm.com/developerworks/mydeveloperworks/blogs/ab16c38e-2f7b-4912-a47e-85682d124d32/?lang=en&9524a188 Mark Webb Line +27 (21) 786 4379 Cell +27 (72) 199 1000 [Poor reception] Fax +27 (86) 551 3075 Skype tomarkwebb Email [hidden email] On 2011/07/20 04:26 AM, Nancy Rusinak wrote: > Hello! > > I'm trying to find a way to get a count of unique values across 6 variables: > > zip 2006 zip2007 zip2008 zip2009 zip2010 zip2011 > 61477 > 61477 41365 > 41365 41365 41365 41365 41365 41365 > > In the data above, I'd like to add a variable called "count." for the first > case, the value of count would be "1" as there is only 1 unique zip in all 6 > columns. For the second case, "count" would equal "2" and for the third > case, count would equal "1" > > I'm new to syntax and would appreciate any handholding you could offer with > accomplishing this. > > My heartfelt thanks if you can help! > > Nancy > > ===================== > 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 Nancy Rusinak-2
See if MULT RESPONSE or AUTORECODE with the /group
and /print options gives you what you want.
Art Kendall Social research Consultants On 7/19/2011 10:26 PM, Nancy Rusinak wrote: ===================== 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 REFCARDHello! I'm trying to find a way to get a count of unique values across 6 variables: zip 2006 zip2007 zip2008 zip2009 zip2010 zip2011 61477 61477 41365 41365 41365 41365 41365 41365 41365 In the data above, I'd like to add a variable called "count." for the first case, the value of count would be "1" as there is only 1 unique zip in all 6 columns. For the second case, "count" would equal "2" and for the third case, count would equal "1" I'm new to syntax and would appreciate any handholding you could offer with accomplishing this. My heartfelt thanks if you can help! Nancy ===================== 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 |
I will be out of the office until August 2nd. I will respond to your email upon my return.
Sincerely, Resha ===================== 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 Nancy Rusinak-2
Have a look to the following link (is from David Marso):
http://www.spsstools.net/Syntax/MultipleResp/CountUniqueOccurencesOfAMultipl eResponse.txt I've tried it but didn't work. However, I think is what you are asking for. Thanks. Joan Casellas Vega Media Research Analyst Phone: +44 7920 761 870 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Nancy Rusinak Sent: 20 July 2011 03:27 To: [hidden email] Subject: Count of unique values across variables Hello! I'm trying to find a way to get a count of unique values across 6 variables: zip 2006 zip2007 zip2008 zip2009 zip2010 zip2011 61477 61477 41365 41365 41365 41365 41365 41365 41365 In the data above, I'd like to add a variable called "count." for the first case, the value of count would be "1" as there is only 1 unique zip in all 6 columns. For the second case, "count" would equal "2" and for the third case, count would equal "1" I'm new to syntax and would appreciate any handholding you could offer with accomplishing this. My heartfelt thanks if you can help! Nancy ===================== 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 |
Administrator
|
Of course it works ;-) Just needed a few changes to fit the current data.
data list list/ zip2006 zip2007 zip2008 zip2009 zip2010 zip2011. begin data 61477 61477 41365 41365 41365 41365 41365 41365 41365 end data. * Copy the array * . VECTOR P=zip2006 TO zip2011 / #TMP(6). LOOP #I=1 to 6. + compute #TMP(#I)=P(#I). END LOOP. * Compare to preceding variables *. LOOP #I=2 to 6. + LOOP #J=1 TO #I-1. + IF #TMP(#I)=#TMP(#J) #TMP(#I)=$SYSMIS. + END LOOP IF MISSING(#TMP(#I)). END LOOP. COMPUTE N=NVALID(#TMP1 TO #TMP5). LIST. ZIP2006 ZIP2007 ZIP2008 ZIP2009 ZIP2010 ZIP2011 N 61477.00 . . . . . 1.00 61477.00 41365.00 . . . . 2.00 41365.00 41365.00 41365.00 41365.00 41365.00 41365.00 1.00 Number of cases read: 3 Number of cases listed: 3
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 joan casellas
Nancy
Try this. DATA LIST LIST / id , zip2006, zip2007, zip2008, zip2009, zip2010, zip2011. BEGIN DATA 1, 61477, 2, 61477, 41365, 3, 41365, 41365, 41365, 41365, 41365, 41365 END DATA. FORMATS id zip2006 to zip2011 (F5.0). VARSTOCASES /MAKE zip FROM zip2006 zip2007 zip2008 zip2009 zip2010 zip2011 /KEEP=id /NULL=DROP. SORT CASES BY id(A) zip(A). MATCH FILES /FILE=* /BY id zip /FIRST=PrimaryFirst /LAST=PrimaryLast. DO IF (PrimaryFirst). COMPUTE MatchSequence=1-PrimaryLast. ELSE. COMPUTE MatchSequence=MatchSequence+1. END IF. LEAVE MatchSequence. FORMATS MatchSequence (f7). COMPUTE InDupGrp=MatchSequence>0. SORT CASES InDupGrp(D). MATCH FILES /FILE=* /DROP=PrimaryFirst InDupGrp MatchSequence. SELECT IF (PrimaryLast=1). EXECUTE. DATASET DECLARE Counts. AGGREGATE /OUTFILE='Counts' /BREAK=id /N_UNIQUE=N. DATASET ACTIVATE Counts. LIST. You end up with the following dataset Counts, which you can merge with your origninal file if you want. ===================================================. id N_UNIQUE 1 1 2 2 3 1 Regards Garry Gelade -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Nancy Rusinak Sent: 20 July 2011 03:27 To: [hidden email] Subject: Count of unique values across variables Hello! I'm trying to find a way to get a count of unique values across 6 variables: zip 2006 zip2007 zip2008 zip2009 zip2010 zip2011 61477 61477 41365 41365 41365 41365 41365 41365 41365 In the data above, I'd like to add a variable called "count." for the first case, the value of count would be "1" as there is only 1 unique zip in all 6 columns. For the second case, "count" would equal "2" and for the third case, count would equal "1" I'm new to syntax and would appreciate any handholding you could offer with accomplishing this. My heartfelt thanks if you can help! Nancy ===================== 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 |
In reply to this post by David Marso
Great!!! Now works perfectly!!!!!
Thanks David!!! Joan Casellas Vega Media Research Analyst Phone: +44 7920 761 870 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: 20 July 2011 17:24 To: [hidden email] Subject: Re: Count of unique values across variables Of course it works ;-) Just needed a few changes to fit the current data. data list list/ zip2006 zip2007 zip2008 zip2009 zip2010 zip2011. begin data 61477 61477 41365 41365 41365 41365 41365 41365 41365 end data. * Copy the array * . VECTOR P=zip2006 TO zip2011 / #TMP(6). LOOP #I=1 to 6. + compute #TMP(#I)=P(#I). END LOOP. * Compare to preceding variables *. LOOP #I=2 to 6. + LOOP #J=1 TO #I-1. + IF #TMP(#I)=#TMP(#J) #TMP(#I)=$SYSMIS. + END LOOP IF MISSING(#TMP(#I)). END LOOP. COMPUTE N=NVALID(#TMP1 TO #TMP5). LIST. ZIP2006 ZIP2007 ZIP2008 ZIP2009 ZIP2010 ZIP2011 N 61477.00 . . . . . 1.00 61477.00 41365.00 . . . . 2.00 41365.00 41365.00 41365.00 41365.00 41365.00 41365.00 1.00 Number of cases read: 3 Number of cases listed: 3 joan casellas wrote: > > Have a look to the following link (is from David Marso): > > http://www.spsstools.net/Syntax/MultipleResp/CountUniqueOccurencesOfAMultipl > eResponse.txt > > I've tried it but didn't work. However, I think is what you are asking > for. > > Thanks. > > > > Joan Casellas Vega > Media Research Analyst > Phone: +44 7920 761 870 > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of > Nancy Rusinak > Sent: 20 July 2011 03:27 > To: [hidden email] > Subject: Count of unique values across variables > > Hello! > > I'm trying to find a way to get a count of unique values across 6 > variables: > > zip 2006 zip2007 zip2008 zip2009 zip2010 zip2011 > 61477 > 61477 41365 > 41365 41365 41365 41365 41365 41365 > > In the data above, I'd like to add a variable called "count." for the > first > case, the value of count would be "1" as there is only 1 unique zip in all > 6 > columns. For the second case, "count" would equal "2" and for the third > case, count would equal "1" > > I'm new to syntax and would appreciate any handholding you could offer > with > accomplishing this. > > My heartfelt thanks if you can help! > > Nancy > > ===================== > 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 > -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Count-of-unique-values-across- variables-tp4614377p4616445.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 |
Administrator
|
In reply to this post by Garry Gelade
Easier to simply aggregate twice after the V2C. Or just use the LOOP code posted previously.
VARSTOCASES /MAKE zip FROM zip2006 zip2007 zip2008 zip2009 zip2010 zip2011 /KEEP=id /NULL=DROP. AGGREGATE OUTFILE * / BREAK id zip / N=N. AGGREGATE OUTFILE * / BREAK ID / unique=N.
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?" |
Free forum by Nabble | Edit this page |