Computing multiple count variables within ID (sans duplicates)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Computing multiple count variables within ID (sans duplicates)

Dale Glaser
Hi all...I have scoured the reference guide and Raynalds' syntax website, but am running into a data structuring obstacle that would greatly benefit from your expertise.

Given a data structure with multiple records per ID as follows:

ID    location     proximity
1        2            1
1        2            1
1        3            2
1        1            2
.
.
286    103        3
286    103        3
286    106        3

Where there are varying amounts of multiple records for each ID (subject #), and location is a unique locale for each ID, and proximity is coded as 1 = < 1 km; 2 = 1-2 km; 3 = > 2km, I am attempting to create three variables (corresponding to the three levels of proximity) that will result in a count of # unique locations (i.e., not counting/summing duplicates) for each subject (e.g., for ID =1 for the three unique locations (with four records) there will be one location < 1 km, 1 location for 1-2 km, and 1 location for > 2km).  So in an ideal world my final database would look like as follows:


ID       prox_le1km   prox_1_2km  prox_ge2km
1         1                    1                1
286     0                     0                2

I was easily able to do this for a variable that did not have duplicates using the aggregate function and breaking by ID and proximity.  But this one has me stumped (I have tried various restructuring and lag options, but to no avail).  I was thinking this was a vector within a looped structure, but again was stumped.

Any advise would be much appreciated.

Thank you very much....Dale Glaser


 
Dale Glaser, Ph.D.
Principal--Glaser Consulting
Lecturer/Adjunct Faculty--SDSU/USD/Alliant
3115 4th Avenue
San Diego, CA 92103
phone: 619-220-0602
fax: 619-220-0412
email: [hidden email]
website: www.glaserconsult.comailing 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


Reply | Threaded
Open this post in threaded view
|

Re: Computing multiple count variables within ID (sans duplicates)

David Marso
Administrator
Double aggregate then C2V.

AGG OUTFILE file / BREAK ID  proximity location /N=N.
DATASET ACTIVATE file.
AGGREGATE OUTFILE * / BREAK ID   proximity /N=N.
CASESTOVARS.

----
Dale Glaser wrote
Hi all...I have scoured the reference guide and Raynalds' syntax website, but am running into a data structuring obstacle that would greatly benefit from your expertise.

Given a data structure with multiple records per ID as follows:

ID    location     proximity
1        2            1
1        2            1
1        3            2
1        1            2

.
.
286    103        3
286    103        3
286    106        3

Where there are varying amounts ofmultiple records for each ID (subject #), and location is a unique locale for each ID, and proximity is coded as 1 = < 1 km; 2 = 1-2 km; 3 = > 2km, I am attempting to create three variables (corresponding to the three levels of proximity) that will result in a count of # unique locations (i.e., not counting/summing duplicates) for each subject (e.g., for ID =1 for the three unique locations (with four records) there will be one location < 1 km, 1 location for 1-2 km, and 1 location for > 2km).  So in an ideal world my final database would look like as follows:


ID       prox_le1km   prox_1_2km  prox_ge2km

1         1                   1                1

286     0                     0                2


I was easily able to do this for a variable that did not have duplicates using the aggregate function and breaking by ID and proximity.  But this one has me stumped (I have tried various restructuring and lag options, but to no avail).  I was thinking this was a vector within a looped structure, but again was stumped.

Any advise would be much appreciated.

Thank you very much....Dale Glaser



 
Dale Glaser, Ph.D.
Principal--Glaser Consulting
Lecturer/Adjunct Faculty--SDSU/USD/Alliant
3115 4th Avenue
San Diego, CA 92103
phone: 619-220-0602
fax: 619-220-0412
email: [hidden email]
website: www.glaserconsult.comailing 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
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?"