| Date: | Wed, 23 Feb 2005 15:53:43 -0500 |
| Reply-To: | thennig@idirect.com |
| Sender: | "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU> |
| From: | Timothy Hennigar <thennig@idirect.com> |
| Organization: | Timothy Hennigar |
| Subject: | Re: Counting unique occurrences per client |
| In-Reply-To: | <s21c6e20.023@GW-IA.HR.STATE.OR.US> |
| Content-Type: | text/plain; charset="us-ascii" |
Not sure if I understand your request fully - or what your
data looks like but here goes:
* Simple data file - 3 records for each of 4 clients, 6 services.
DATA LIST /id 1-3 Client 4 Svc1 6 Svc2 8 Svc3 10 Svc4 12 Svc5 14 Svc6
16.
BEGIN DATA.
1 1 0 0 1 0 0 0
2 2 0 0 0 1 0 1
3 3 1 0 0 1 0 1
4 4 1 0 0 1 0 0
5 1 0 0 1 0 0 0
6 2 1 0 0 1 0 1
7 3 1 1 1 1 0 1
8 4 1 1 0 1 0 1
9 1 0 0 1 0 0 0
10 2 1 0 0 1 0 1
11 3 1 1 0 1 0 1
12 4 1 0 0 1 0 1
END DATA.
EXECUTE.
CD 'C:\temp'.
SORT CASES BY client (A).
AGGREGATE OUTFILE = "services.sav"
/break = client
/max1 = max(svc1)
/max2 = max(svc2)
/max3 = max(svc3)
/max4 = max(svc4)
/max5 = max(svc5)
/max6 = max(svc6)
.
EXECUTE.
GET FILE "services.sav".
COUNT numserv = max1 max2 max3 max4 max5 max6 (1).
CROSSTAB
/TABLES client
BY numserv
/ CELLS=COUNT.
EXECUTE.
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
Patrick MCINTIRE
Sent: Wednesday, February 23, 2005 2:51 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Counting unique occurrences per client
Good day,
I am trying to count the number of unique services per client. I want
the code to read each record within a set of records per client, and
then count the unique services. There are duplicate services with
different episode dates per client, and there are several clients in the
file. I remember doing a similar routine in FORTRAN but can't seem to
get it to work in SPSS. So far, I've done the following:
DO IF (CLIENT EQ LAG(CLIENT)) AND SERVICE NE LAG(SERVICE)).
COUNT = COUNT + 1.
COMPUTE NUMSVC = MAX(COUNT).
IF (CLIENT NE LAG(CLIENT)) STOP = 1.
END IF (STOP = 1).
This does not accumulate a count of unique services per client. I also
tried a LOOP routine but it did the same as the above. Any ideas?
Thanks in advance.
Patrick
Patrick McIntire, Ph.D.
Forecasting and Performance Measurement
Dept of Human Services
500 Summer St NE, E23
Salem, OR 97301-1067
503 945-5667
Fax: 503 378-2897
patrick.mcintire@state.or.us
|