Date: Tue, 4 May 2004 10:35:51 +0100 "Smith, Anne" "SPSSX(r) Discussion" "Smith, Anne" Re: Counting Unique Occurrences Across Variables To: Henrik Lolle

Hi I asked the same question last year. If you know the possible values in your variables, then a variation of the following syntax would work (with thanks to 'simonpf' ) :

data list list/case L306 L305 L304 result. begin data. 1 0 0 200303 1 3 0 0 0 0 4 200304 200304 0 1 5 200306 0 200304 2 6 200305 0 0 1 9 200306 0 200304 2 12 200305 200304 200303 3 13 0 0 0 0 14 0 200304 0 1 16 . . 200304 1 17 200304 0 200304 1 23 200302 200304 200304 2 27 200304 200304 200303 2 end data.

compute unique=0. do repeat x=200300 to 200310. /* minimum to maximum */ if any(x,L306 to L304) unique=unique+1. end repeat. exe. list.

Anne Smith Data Modelling Manager, Business Insight and Analytical Solutions, D&B Tel : 01494 422492 email : smithanne@dnb.com

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Henrik Lolle Sent: 03 May 2004 12:48 To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: Counting Unique Occurrences Across Variables

You could make two arrays. One for the existing variables and a new one with a number of cells equal to the maximum value occuring in the existing variables. Then make one loop through the existing variables where you transfer the values to the new array and where you use the values as array index. Afterwards you can count number of nonmissing values accross the new variables.

Best, Henrik

At 09:28 03-05-04, Mark Webb wrote: >The COUNT command counts the number of occurrences across variables. Is >there a command that reports the number of unique occurrence across >variables. An example will be demonstrate what I'm after. > >V1 V2 V3 Desired Answer > >1 2 3 3 >1 2 1 2 i.e. the '1' is only counted once. > >Any suggestions will be appreciated. > > > >Mark Webb >TargetLink Research >P O Box 13040 Mowbray 7705 >1st Floor, Standard Bank Building >37 Main Rd, Mowbray, Cape Town >Phone 021-689-8848 >Fax 021-686-9493 >Cell 072 199 1000 >e-mail targetlk@iafrica.com

*********************************************************** Assistant Professor Henrik Lolle Department of Economics, Politics and Public Administration Aalborg University Fibigerstraede 1 DK 9220 Aalborg East http://www.socsci.auc.dk/institut2/dansk/empl/lolle.htm ***********************************************************

Back to: Top of message | Previous page | Main SPSSX-L page