|
Great!!! Now works perfectly!!!!!
Thanks David!!!
Joan Casellas Vega
Media Research Analyst
Phone: +44 7920 761 870
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
David Marso
Sent: 20 July 2011 17:24
To: SPSSX-L@LISTSERV.UGA.EDU
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:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
> Nancy Rusinak
> Sent: 20 July 2011 03:27
> To: SPSSX-L@LISTSERV.UGA.EDU
> 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
> LISTSERV@LISTSERV.UGA.EDU (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
> LISTSERV@LISTSERV.UGA.EDU (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
LISTSERV@LISTSERV.UGA.EDU (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
LISTSERV@LISTSERV.UGA.EDU (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
|