|
Hello
I tend to use SPSS for simple data-analysis and so am not as acquainted with its wider functions and syntax as I should be. Hence I have a simple (and probably straightforward) problem that is frustrating me. I am analysing a crime data-base and need to find if there are multiple offenders incolved in an offence. My guide is the crime number for the offence - however many times the crime number is repeated indicates the number of offenders. So - I need to recode (or compute?) a new variable from the variable 'crimeno' which translates the number of times the crime number recurs into a value for the new variable. For example, if the crime number 30445567 occurs three times, this should be recoded into the value '3' in the new variable. Likewise if the number 34512743 occurs three times, it should also be recoded into the value '3' in the new variable. Similarly, if the number 20566774 occurs 8 times, then it is recoded as '8' in the new variable. And so on. Simple.... (or it should be!) I've tried using a frequency function to assign the new values but without success so far. If anyone has an easy-fix procedure I could use or other suggestions I'd be extremely grateful!! thanks -- =============================== Dr. Michael McGuire London Metropolitan University =============================== |
|
Michael,
The solution is to use Aggregate along with the option to add new variables to the existing data file. In syntax this would be Aggregate outfile=* mode=addvariables/break=crimeno/offendercout=nu. You can also do all of this through the menu system: Data dropdown box in the Data window. I'm unsure whether you want this or to create a new file with the number of times each offender is listed. Gene Maguin |
|
In reply to this post by mmcguire
Apparently your database has one record per crime occurrence, and
"crimeno" is actually a "crime code", the coded designation of a single type of offense. If this is the case, the solution is AGGREGATE. This function creates a new file with fewer records, each representing a group of former records. In your case, each new record would represent a crime type (a crime number in your jargon), and you can create variables summarizing the group of occurrences of that crime, including the number of times it showed up in your database. In a syntax window, you may write: SORT CASES BY CRIMENO. AGGREGATE OUTFILE * /PRESORTED/BREAK CRIMENO /OCCURRENCES 'Number of occurrences'= nu. This first sorts your working file by crime type. Then it creates a new working file with one record per crime type, containing only two variables: the crime type (CRIMENO) used as an aggregating key, and OCCURRENCES representing the number of times that crime appears in your original database. The function NU defining OCCURRENCES is the Unweighted Number of cases in each group (a "group" is the bunch of original records with the same crime code). AGGREGATE can be also be obtained from the Data Menu. It is straightforward: Data -Aggregate, then use CRIMENO as break variable, and then include the number of cases as variable (one of the choices in the dialog box). You can also create other aggregate variables (such as the average age of offenders, or the proportion of males, if you happen to have their age or gender in the original records). This new working file could then be saved to the disk for future use if you want. Hector -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of mmcguire Sent: 16 July 2007 12:39 To: [hidden email] Subject: simple question Hello I tend to use SPSS for simple data-analysis and so am not as acquainted with its wider functions and syntax as I should be. Hence I have a simple (and probably straightforward) problem that is frustrating me. I am analysing a crime data-base and need to find if there are multiple offenders incolved in an offence. My guide is the crime number for the offence - however many times the crime number is repeated indicates the number of offenders. So - I need to recode (or compute?) a new variable from the variable 'crimeno' which translates the number of times the crime number recurs into a value for the new variable. For example, if the crime number 30445567 occurs three times, this should be recoded into the value '3' in the new variable. Likewise if the number 34512743 occurs three times, it should also be recoded into the value '3' in the new variable. Similarly, if the number 20566774 occurs 8 times, then it is recoded as '8' in the new variable. And so on. Simple.... (or it should be!) I've tried using a frequency function to assign the new values but without success so far. If anyone has an easy-fix procedure I could use or other suggestions I'd be extremely grateful!! thanks -- =============================== Dr. Michael McGuire London Metropolitan University =============================== |
|
In reply to this post by Maguin, Eugene
I forgot to add that you can also ADD the aggregate variables to
your original file, as Gene Maguin suggests, but this is an additional quirk, involving going up to the aggregate level and then back to the elementary level. Since your acquaintance with SPSS seems to be still elementary, I recommended doing just the aggregating, leaving the ADD VARIABLES option for later. Hector -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin Sent: 16 July 2007 13:07 To: [hidden email] Subject: Re: simple question Michael, The solution is to use Aggregate along with the option to add new variables to the existing data file. In syntax this would be Aggregate outfile=* mode=addvariables/break=crimeno/offendercout=nu. You can also do all of this through the menu system: Data dropdown box in the Data window. I'm unsure whether you want this or to create a new file with the number of times each offender is listed. Gene Maguin |
| Free forum by Nabble | Edit this page |
