|
Hello.
I am struggling to write a generic syntax to extract and manipulate crime data for analysis. In the section I am stuck on, all text fields are taken from the server, identified by the CrimeRef for that case. CASETOVARS is used to group together the text fields for each case, and are then used to create a single text field for each crime called MO_FREETEXT via CONCAT. My problem is that each time this syntax is run, it can bring back different numbers of 'crime_text' fields depending on what crimes are being selected. The syntax currently used (see below) fails if there are less than 13 'crime_text' fields, and conversely will not pick up crime_text.14/15/16 etc. Is there a way of instructing SPSS to concatenate all the 'crime_text' fields without specifying the number, separated by a space? I am using SPSS 16. Many Thanks Caroline Caroline PETTITT-MORRIS Intelligence Analyst Greyfriars Police Station Greyfriars Bedford MK40 1HR Tel: 01234 275314 E-mail: [hidden email] SORT CASES BY CrimeRef . CASESTOVARS /ID = CrimeRef /GROUPBY = INDEX . STRING MO_FREETEXT (A5000). COMPUTE MO_FREETEXT = CONCAT(RTRIM(Crime_text.1)," ",RTRIM(Crime_text.2)," ",RTRIM(Crime_text.3)," ",RTRIM(Crime_text.4)," " ,RTRIM(Crime_text.5)," ",RTRIM(Crime_text.6)," ",RTRIM(Crime_text.7)," ",RTRIM(Crime_text.8)," ",RTRIM(Crime_text.9)," " ,RTRIM(Crime_text.10)," ",RTRIM(Crime_text.11)," ",RTRIM(Crime_text.12)," ",RTRIM(Crime_text.13)). EXECUTE . ********************************************************************** 'Bedfordshire police are now recruiting - visit www.bedfordshire.police.uk for more information ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept for the presence of computer viruses. ******************************************************************************** Internet email is not to be treated as a secure means of communication. Bedfordshire Police monitors all Internet email activity and content. ******************************************************************************** ====================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 |
|
The easiest solution that comes to mind is to use Python programmability to dynamically build the Compute command based on which variables are found in the dataset.
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Pettitt-Morris Caroline Sent: Wednesday, December 03, 2008 9:08 AM To: [hidden email] Subject: Concatenate Hello. I am struggling to write a generic syntax to extract and manipulate crime data for analysis. In the section I am stuck on, all text fields are taken from the server, identified by the CrimeRef for that case. CASETOVARS is used to group together the text fields for each case, and are then used to create a single text field for each crime called MO_FREETEXT via CONCAT. My problem is that each time this syntax is run, it can bring back different numbers of 'crime_text' fields depending on what crimes are being selected. The syntax currently used (see below) fails if there are less than 13 'crime_text' fields, and conversely will not pick up crime_text.14/15/16 etc. Is there a way of instructing SPSS to concatenate all the 'crime_text' fields without specifying the number, separated by a space? I am using SPSS 16. Many Thanks Caroline Caroline PETTITT-MORRIS Intelligence Analyst Greyfriars Police Station Greyfriars Bedford MK40 1HR Tel: 01234 275314 E-mail: [hidden email] SORT CASES BY CrimeRef . CASESTOVARS /ID = CrimeRef /GROUPBY = INDEX . STRING MO_FREETEXT (A5000). COMPUTE MO_FREETEXT = CONCAT(RTRIM(Crime_text.1)," ",RTRIM(Crime_text.2)," ",RTRIM(Crime_text.3)," ",RTRIM(Crime_text.4)," " ,RTRIM(Crime_text.5)," ",RTRIM(Crime_text.6)," ",RTRIM(Crime_text.7)," ",RTRIM(Crime_text.8)," ",RTRIM(Crime_text.9)," " ,RTRIM(Crime_text.10)," ",RTRIM(Crime_text.11)," ",RTRIM(Crime_text.12)," ",RTRIM(Crime_text.13)). EXECUTE . ********************************************************************** 'Bedfordshire police are now recruiting - visit www.bedfordshire.police.uk for more information ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept for the presence of computer viruses. ******************************************************************************** Internet email is not to be treated as a secure means of communication. Bedfordshire Police monitors all Internet email activity and content. ******************************************************************************** ======= 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 ===================== 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 |
|
In reply to this post by Pettitt-Morris Caroline
I only have a vague impression of what you are asking. It is much more
common to parse long strings rather than create them? Something that might be related to your goals. When I had a series of charges in arbitrary order for crimes I did something like this. AUTORECODE with the /group specification MULT RESPONSE on the resulting numeric variables. Please give more detail about what you have as data and what you are trying to achieve. Perhaps a small set of data with HAVE variables and WANT variables. Art Kendall Social Research Consultants Pettitt-Morris Caroline wrote: > Hello. > > > > I am struggling to write a generic syntax to extract and manipulate > crime data for analysis. > > In the section I am stuck on, all text fields are taken from the server, > identified by the CrimeRef for that case. > > CASETOVARS is used to group together the text fields for each case, and > are then used to create a single text field for each crime called > MO_FREETEXT via CONCAT. > > > > My problem is that each time this syntax is run, it can bring back > different numbers of 'crime_text' fields depending on what crimes are > being selected. > > The syntax currently used (see below) fails if there are less than 13 > 'crime_text' fields, and conversely will not pick up crime_text.14/15/16 > etc. > > > > Is there a way of instructing SPSS to concatenate all the 'crime_text' > fields without specifying the number, separated by a space? > > > > I am using SPSS 16. > > > > Many Thanks > > > > Caroline > > > > > Caroline PETTITT-MORRIS > > Intelligence Analyst > > Greyfriars Police Station > > Greyfriars > > Bedford > > MK40 1HR > > > > Tel: 01234 275314 > > E-mail: [hidden email] > > > > > > > > SORT CASES BY CrimeRef . > > CASESTOVARS > > /ID = CrimeRef > > /GROUPBY = INDEX . > > > > STRING MO_FREETEXT (A5000). > > COMPUTE MO_FREETEXT = CONCAT(RTRIM(Crime_text.1)," > ",RTRIM(Crime_text.2)," ",RTRIM(Crime_text.3)," ",RTRIM(Crime_text.4)," > " > > ,RTRIM(Crime_text.5)," ",RTRIM(Crime_text.6)," ",RTRIM(Crime_text.7)," > ",RTRIM(Crime_text.8)," ",RTRIM(Crime_text.9)," " > > ,RTRIM(Crime_text.10)," ",RTRIM(Crime_text.11)," > ",RTRIM(Crime_text.12)," ",RTRIM(Crime_text.13)). > > EXECUTE . > > > ********************************************************************** > 'Bedfordshire police are now recruiting - visit www.bedfordshire.police.uk for more information > > ********************************************************************** > This email and any files transmitted with it are confidential and > intended solely for the use of the individual or entity to whom they > are addressed. If you have received this email in error please notify > the system manager. > This footnote also confirms that this email message has been swept for the presence of computer viruses. > ******************************************************************************** > Internet email is not to be treated as a secure means of communication. > Bedfordshire Police monitors all Internet email activity and content. > ******************************************************************************** > > > > =================== > 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 > > > ===================== 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
Art Kendall
Social Research Consultants |
|
Does this match your data:
Crimeref crime_text 1 this is 1 the first 1 case 2 this is a 2 different 2 case with 2 more notes And is this what is desired: Crimeref mo_freetext 1 this is the first case 2 this is a different case with more notes If this is accurate, I think VECTOR and LOOP, followed by DO REPEAT will give you what you need. I am assuming there is a practical limit (no one ever writes more than 50 fields, for example). You will need to edit the code below so the vector and loop are longer than that limit, and the concatenate grabs all the variables. Warning: this solution is not elegant... ** sample data for the list-- use your own. DATA LIST list /CrimeRef (f8.0) crime_text (a10). BEGIN DATA 1 'this is a' 1 'sample of' 1 'the crime' 1 'data' 2 'another' 2 'sample ' 2 'with more' 2 'fields' 2 'used for' 2 'processing' 3 'short case' end data. list. ** order variable for the looping index. COMPUTE seq = $CASENUM. RANK seq BY crimeref /RANK INTO ordervar. FORMAT ordervar (F8.0). ** Create variables to be concatentated. ** the first value in the parens is the maximum number of fields per crimeref. ** the second value in the parens is the length of the crime_text field. ** edit with the appropriate values. VECTOR crime_text(15 a10). LOOP #i = 1 TO 15. IF ordervar = (#i) crime_text(#i) = crime_text. END LOOP. ** copy down the values of the individual crime_text fields. ** edit to match the number of variables in the VECTOR. DO REPEAT x = crime_text1 TO crime_text15. IF LENGTH(RTRIM(x) )= 0 AND crimeref = LAG(crimeref) x = LAG(x). END REPEAT. ** concatenate. ** copy, paste and edit the CONCAT elements to match the maximum number of text fields. STRING MO_FREETEXT (A5000). COMPUTE MO_FREETEXT = CONCAT( RTRIM(Crime_text1)," ", RTRIM(Crime_text2)," ", RTRIM(Crime_text3)," ", RTRIM(Crime_text4)," ", RTRIM(Crime_text5)," ", RTRIM(Crime_text6)," ", RTRIM(Crime_text7)," ", RTRIM(Crime_text8)," ", RTRIM(Crime_text9)," ", RTRIM(Crime_text10)," ", RTRIM(Crime_text11)," ", RTRIM(Crime_text12)," ", RTRIM(Crime_text13)," ", RTRIM(Crime_text14)," ", RTRIM(Crime_text15) ). ** select cases with the complete mo_freetext field. SORT CASES BY crimeref (a) ordervar (d). COMPUTE keepit = crimeref NE LAG(crimeref ) OR $CASENUM = 1. SELECT IF keepit = 1. FREQUEN mo_freetext. Hope this helps -jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Art Kendall Sent: Wednesday, December 03, 2008 11:09 AM To: [hidden email] Subject: Re: Concatenate I only have a vague impression of what you are asking. It is much more common to parse long strings rather than create them? Something that might be related to your goals. When I had a series of charges in arbitrary order for crimes I did something like this. AUTORECODE with the /group specification MULT RESPONSE on the resulting numeric variables. Please give more detail about what you have as data and what you are trying to achieve. Perhaps a small set of data with HAVE variables and WANT variables. Art Kendall Social Research Consultants Pettitt-Morris Caroline wrote: > Hello. > > > > I am struggling to write a generic syntax to extract and manipulate > crime data for analysis. > > In the section I am stuck on, all text fields are taken from the server, > identified by the CrimeRef for that case. > > CASETOVARS is used to group together the text fields for each case, and > are then used to create a single text field for each crime called > MO_FREETEXT via CONCAT. > > > > My problem is that each time this syntax is run, it can bring back > different numbers of 'crime_text' fields depending on what crimes are > being selected. > > The syntax currently used (see below) fails if there are less than 13 > 'crime_text' fields, and conversely will not pick up > etc. > > > > Is there a way of instructing SPSS to concatenate all the 'crime_text' > fields without specifying the number, separated by a space? > > > > I am using SPSS 16. > > > > Many Thanks > > > > Caroline > > > > > Caroline PETTITT-MORRIS > > Intelligence Analyst > > Greyfriars Police Station > > Greyfriars > > Bedford > > MK40 1HR > > > > Tel: 01234 275314 > > E-mail: [hidden email] > > > > > > > > SORT CASES BY CrimeRef . > > CASESTOVARS > > /ID = CrimeRef > > /GROUPBY = INDEX . > > > > STRING MO_FREETEXT (A5000). > > COMPUTE MO_FREETEXT = CONCAT(RTRIM(Crime_text.1)," > ",RTRIM(Crime_text.2)," ",RTRIM(Crime_text.3)," > " > > ,RTRIM(Crime_text.5)," ",RTRIM(Crime_text.6)," ",RTRIM(Crime_text.7)," > ",RTRIM(Crime_text.8)," ",RTRIM(Crime_text.9)," " > > ,RTRIM(Crime_text.10)," ",RTRIM(Crime_text.11)," > ",RTRIM(Crime_text.12)," ",RTRIM(Crime_text.13)). > > EXECUTE . > > > ********************************************************************** > 'Bedfordshire police are now recruiting - visit > > ********************************************************************** > This email and any files transmitted with it are confidential and > intended solely for the use of the individual or entity to whom they > are addressed. If you have received this email in error please notify > the system manager. > This footnote also confirms that this email message has been swept for the presence of computer viruses. > ************************************************************************ ******** > Internet email is not to be treated as a secure means of communication. > Bedfordshire Police monitors all Internet email activity and content. > ************************************************************************ ******** > > > > =================== > 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 > > > ===================== 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 ===================== 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 |
|
Jim et al.,
Thank you for your help on this. The syntax below did exactly what I needed, elegant or not! Many Thanks again to all those who replied. Caroline Pettitt-Morris -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marks, Jim Sent: 04 December 2008 01:02 To: [hidden email] Subject: Re: Concatenate Does this match your data: Crimeref crime_text 1 this is 1 the first 1 case 2 this is a 2 different 2 case with 2 more notes And is this what is desired: Crimeref mo_freetext 1 this is the first case 2 this is a different case with more notes If this is accurate, I think VECTOR and LOOP, followed by DO REPEAT will give you what you need. I am assuming there is a practical limit (no one ever writes more than 50 fields, for example). You will need to edit the code below so the vector and loop are longer than that limit, and the concatenate grabs all the variables. Warning: this solution is not elegant... ** sample data for the list-- use your own. DATA LIST list /CrimeRef (f8.0) crime_text (a10). BEGIN DATA 1 'this is a' 1 'sample of' 1 'the crime' 1 'data' 2 'another' 2 'sample ' 2 'with more' 2 'fields' 2 'used for' 2 'processing' 3 'short case' end data. list. ** order variable for the looping index. COMPUTE seq = $CASENUM. RANK seq BY crimeref /RANK INTO ordervar. FORMAT ordervar (F8.0). ** Create variables to be concatentated. ** the first value in the parens is the maximum number of fields per crimeref. ** the second value in the parens is the length of the crime_text field. ** edit with the appropriate values. VECTOR crime_text(15 a10). LOOP #i = 1 TO 15. IF ordervar = (#i) crime_text(#i) = crime_text. END LOOP. ** copy down the values of the individual crime_text fields. ** edit to match the number of variables in the VECTOR. DO REPEAT x = crime_text1 TO crime_text15. IF LENGTH(RTRIM(x) )= 0 AND crimeref = LAG(crimeref) x = LAG(x). END REPEAT. ** concatenate. ** copy, paste and edit the CONCAT elements to match the maximum number of text fields. STRING MO_FREETEXT (A5000). COMPUTE MO_FREETEXT = CONCAT( RTRIM(Crime_text1)," ", RTRIM(Crime_text2)," ", RTRIM(Crime_text3)," ", RTRIM(Crime_text4)," ", RTRIM(Crime_text5)," ", RTRIM(Crime_text6)," ", RTRIM(Crime_text7)," ", RTRIM(Crime_text8)," ", RTRIM(Crime_text9)," ", RTRIM(Crime_text10)," ", RTRIM(Crime_text11)," ", RTRIM(Crime_text12)," ", RTRIM(Crime_text13)," ", RTRIM(Crime_text14)," ", RTRIM(Crime_text15) ). ** select cases with the complete mo_freetext field. SORT CASES BY crimeref (a) ordervar (d). COMPUTE keepit = crimeref NE LAG(crimeref ) OR $CASENUM = 1. SELECT IF keepit = 1. FREQUEN mo_freetext. Hope this helps -jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Art Kendall Sent: Wednesday, December 03, 2008 11:09 AM To: [hidden email] Subject: Re: Concatenate I only have a vague impression of what you are asking. It is much more common to parse long strings rather than create them? Something that might be related to your goals. When I had a series of charges in arbitrary order for crimes I did something like this. AUTORECODE with the /group specification MULT RESPONSE on the resulting numeric variables. Please give more detail about what you have as data and what you are trying to achieve. Perhaps a small set of data with HAVE variables and WANT variables. Art Kendall Social Research Consultants Pettitt-Morris Caroline wrote: > Hello. > > > > I am struggling to write a generic syntax to extract and manipulate > crime data for analysis. > > In the section I am stuck on, all text fields are taken from the server, > identified by the CrimeRef for that case. > > CASETOVARS is used to group together the text fields for each case, and > are then used to create a single text field for each crime called > MO_FREETEXT via CONCAT. > > > > My problem is that each time this syntax is run, it can bring back > different numbers of 'crime_text' fields depending on what crimes are > being selected. > > The syntax currently used (see below) fails if there are less than 13 > 'crime_text' fields, and conversely will not pick up > etc. > > > > Is there a way of instructing SPSS to concatenate all the 'crime_text' > fields without specifying the number, separated by a space? > > > > I am using SPSS 16. > > > > Many Thanks > > > > Caroline > > > > > Caroline PETTITT-MORRIS > > Intelligence Analyst > > Greyfriars Police Station > > Greyfriars > > Bedford > > MK40 1HR > > > > Tel: 01234 275314 > > E-mail: [hidden email] > > > > > > > > SORT CASES BY CrimeRef . > > CASESTOVARS > > /ID = CrimeRef > > /GROUPBY = INDEX . > > > > STRING MO_FREETEXT (A5000). > > COMPUTE MO_FREETEXT = CONCAT(RTRIM(Crime_text.1)," > ",RTRIM(Crime_text.2)," ",RTRIM(Crime_text.3)," > " > > ,RTRIM(Crime_text.5)," ",RTRIM(Crime_text.6)," ",RTRIM(Crime_text.7)," > ",RTRIM(Crime_text.8)," ",RTRIM(Crime_text.9)," " > > ,RTRIM(Crime_text.10)," ",RTRIM(Crime_text.11)," > ",RTRIM(Crime_text.12)," ",RTRIM(Crime_text.13)). > > EXECUTE . > > > ********************************************************************** > 'Bedfordshire police are now recruiting - visit > > ********************************************************************** > This email and any files transmitted with it are confidential and > intended solely for the use of the individual or entity to whom they > are addressed. If you have received this email in error please notify > the system manager. > This footnote also confirms that this email message has been swept for the presence of computer viruses. > ************************************************************************ ******** > Internet email is not to be treated as a secure means of communication. > Bedfordshire Police monitors all Internet email activity and content. > ************************************************************************ ******** > > > > =================== > 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 > > > ===================== 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 ===================== 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 ===================== 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 |
|
In reply to this post by Marks, Jim
Hi Caroline!
This is how I understood your question (see below). The CONCAT is used from var 1 to var n, such that n is assigned dynamically. Cheers!! Albert-Jan * sample data (after CASESTOVARS). data list free /dummy. begin data 0 end data. vector crime_text (40, a10). * actual code. string no_freetext (a4000). begin program. import spss, spssaux, re names = " ".join(spssaux.GetVariableNamesList()) pattern = re.compile('crime_text\d+') target = pattern.findall(names) spss.Submit("compute no_freetext = replace(concat(%s to %s),' ', '')." % (target[0], target[-1])) end program. --- On Thu, 12/4/08, Marks, Jim <[hidden email]> wrote: > From: Marks, Jim <[hidden email]> > Subject: Re: Concatenate > To: [hidden email] > Date: Thursday, December 4, 2008, 2:01 AM > Does this match your data: > > Crimeref crime_text > 1 this is > 1 the first > 1 case > 2 this is a > 2 different > 2 case with > 2 more notes > > And is this what is desired: > > Crimeref mo_freetext > 1 this is the first case > 2 this is a different case with more notes > > If this is accurate, I think VECTOR and LOOP, followed by > DO REPEAT will > give you what you need. > > I am assuming there is a practical limit (no one ever > writes more than > 50 fields, for example). You will need to edit the code > below so the > vector and loop are longer than that limit, and the > concatenate grabs > all the variables. > > Warning: this solution is not elegant... > > ** sample data for the list-- use your own. > DATA LIST list /CrimeRef (f8.0) crime_text (a10). > BEGIN DATA > 1 'this is a' > 1 'sample of' > 1 'the crime' > 1 'data' > 2 'another' > 2 'sample ' > 2 'with more' > 2 'fields' > 2 'used for' > 2 'processing' > 3 'short case' > end data. > list. > > ** order variable for the looping index. > COMPUTE seq = $CASENUM. > RANK seq BY crimeref /RANK INTO ordervar. > FORMAT ordervar (F8.0). > > ** Create variables to be concatentated. > ** the first value in the parens is the maximum number of > fields per > crimeref. > ** the second value in the parens is the length of the > crime_text field. > ** edit with the appropriate values. > > VECTOR crime_text(15 a10). > LOOP #i = 1 TO 15. > IF ordervar = (#i) crime_text(#i) = crime_text. > END LOOP. > > ** copy down the values of the individual crime_text > fields. > ** edit to match the number of variables in the VECTOR. > > DO REPEAT x = crime_text1 TO crime_text15. > IF LENGTH(RTRIM(x) )= 0 AND crimeref = LAG(crimeref) x = > LAG(x). > END REPEAT. > > ** concatenate. > ** copy, paste and edit the CONCAT elements to match the > maximum number > of text fields. > > STRING MO_FREETEXT (A5000). > > COMPUTE MO_FREETEXT = CONCAT( > RTRIM(Crime_text1)," ", > RTRIM(Crime_text2)," ", > RTRIM(Crime_text3)," ", > RTRIM(Crime_text4)," ", > RTRIM(Crime_text5)," ", > RTRIM(Crime_text6)," ", > RTRIM(Crime_text7)," ", > RTRIM(Crime_text8)," ", > RTRIM(Crime_text9)," ", > RTRIM(Crime_text10)," ", > RTRIM(Crime_text11)," ", > RTRIM(Crime_text12)," ", > RTRIM(Crime_text13)," ", > RTRIM(Crime_text14)," ", > RTRIM(Crime_text15) > ). > > ** select cases with the complete mo_freetext field. > SORT CASES BY crimeref (a) ordervar (d). > COMPUTE keepit = crimeref NE LAG(crimeref ) OR $CASENUM = > 1. > SELECT IF keepit = 1. > FREQUEN mo_freetext. > > Hope this helps > > -jim > > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]] > On Behalf Of > Art Kendall > Sent: Wednesday, December 03, 2008 11:09 AM > To: [hidden email] > Subject: Re: Concatenate > > I only have a vague impression of what you are asking. It > is much more > common to parse long strings rather than create them? > > Something that might be related to your goals. When I had > a series of > charges in arbitrary order for crimes I did something like > this. > > AUTORECODE with the /group specification > MULT RESPONSE on the resulting numeric variables. > > Please give more detail about what you have as data and > what you are > trying to achieve. Perhaps a small set of data with HAVE > variables and > WANT variables. > > > Art Kendall > Social Research Consultants > > Pettitt-Morris Caroline wrote: > > Hello. > > > > > > > > I am struggling to write a generic syntax to extract > and manipulate > > crime data for analysis. > > > > In the section I am stuck on, all text fields are > taken from the > server, > > identified by the CrimeRef for that case. > > > > CASETOVARS is used to group together the text fields > for each case, > and > > are then used to create a single text field for each > crime called > > MO_FREETEXT via CONCAT. > > > > > > > > My problem is that each time this syntax is run, it > can bring back > > different numbers of 'crime_text' fields > depending on what crimes are > > being selected. > > > > The syntax currently used (see below) fails if there > are less than 13 > > 'crime_text' fields, and conversely will not > pick up > crime_text.14/15/16 > > etc. > > > > > > > > Is there a way of instructing SPSS to concatenate all > the 'crime_text' > > fields without specifying the number, separated by a > space? > > > > > > > > I am using SPSS 16. > > > > > > > > Many Thanks > > > > > > > > Caroline > > > > > > > > > > Caroline PETTITT-MORRIS > > > > Intelligence Analyst > > > > Greyfriars Police Station > > > > Greyfriars > > > > Bedford > > > > MK40 1HR > > > > > > > > Tel: 01234 275314 > > > > E-mail: > [hidden email] > > > > > > > > > > > > > > > > SORT CASES BY CrimeRef . > > > > CASESTOVARS > > > > /ID = CrimeRef > > > > /GROUPBY = INDEX . > > > > > > > > STRING MO_FREETEXT (A5000). > > > > COMPUTE MO_FREETEXT = > CONCAT(RTRIM(Crime_text.1)," > > ",RTRIM(Crime_text.2)," > ",RTRIM(Crime_text.3)," > ",RTRIM(Crime_text.4)," > > " > > > > ,RTRIM(Crime_text.5)," > ",RTRIM(Crime_text.6)," > ",RTRIM(Crime_text.7)," > > ",RTRIM(Crime_text.8)," > ",RTRIM(Crime_text.9)," " > > > > ,RTRIM(Crime_text.10)," > ",RTRIM(Crime_text.11)," > > ",RTRIM(Crime_text.12)," > ",RTRIM(Crime_text.13)). > > > > EXECUTE . > > > > > > > ********************************************************************** > > 'Bedfordshire police are now recruiting - visit > www.bedfordshire.police.uk for more information > > > > > ********************************************************************** > > This email and any files transmitted with it are > confidential and > > intended solely for the use of the individual or > entity to whom they > > are addressed. If you have received this email in > error please notify > > the system manager. > > This footnote also confirms that this email message > has been swept for > the presence of computer viruses. > > > ************************************************************************ > ******** > > Internet email is not to be treated as a secure means > of > communication. > > Bedfordshire Police monitors all Internet email > activity and content. > > > ************************************************************************ > ******** > > > > > > > > =================== > > 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 > > > > > > > > ===================== > 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 > > ===================== > 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 ===================== 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 |
|
Hello!
I am not very familar with SPSS syntax, so perhaps my question is a bit stupid: Is there in SPSS for Windows 16.0 a format (value label or variable type) similar to the percentw.d format in SAS to show numbers like 0.1 in form of 10% in an output or the SPSS table? Any hints are welcome. Thanks in advance. Mit freundlichen Grüßen Carina -- Dr. Carina Ortseifen Abteilung Anwendungen Tel. (06221) 54-45 41, Fax (06221) 54-55 81 [hidden email] Ruprecht-Karls-Universität Heidelberg Universitätsrechenzentrum (URZ) Im Neuenheimer Feld 293, 69120 Heidelberg http://www.urz.uni-heidelberg.de -- 13. KSFE 2009 in Halle: www.ksfe2009.uni-halle.de ===================== 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 |
|
Hi
This bug exist since a few versions. Here is an illustration of the bug as well as a work around. DATASET CLOSE ALL. NEW FILE. GET FILE='C:\Program Files\SPSS\employee data.sav'. COMPUTE nobreak=1. AGG /BREAK=nobreak /maxsal=MAX(salary). COMPUTE salpc=salary * 100 / maxsal. * Following GGRAPH does not display the % sign. FORMATS salpc(PCT3). * Chart Builder. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=jobcat MEAN(salpc)[name= "MEAN_salpc"] MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE LABEL="Format of salpc=PCT8 (is ignored)". BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: jobcat=col(source(s), name("jobcat"), unit.category()) DATA: MEAN_salpc=col(source(s), name("MEAN_salpc")) GUIDE: axis(dim(1), label("Employment Category")) GUIDE: axis(dim(2), label("Mean salpc")) SCALE: cat(dim(1), include("1", "2", "3")) SCALE: linear(dim(2), include(0)) ELEMENT: interval(position(jobcat*MEAN_salpc), shape.interior( shape.square)) END GPL. * Following GGRAPH *does* display the % sign. SET CCA '-,,%,' . FORMATS salpc(CCA3.1) . * Chart Builder. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=jobcat MEAN(salpc)[name= "MEAN_salpc"] MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE LABEL="Format of salpc=CCA3 (works)". BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: jobcat=col(source(s), name("jobcat"), unit.category()) DATA: MEAN_salpc=col(source(s), name("MEAN_salpc")) GUIDE: axis(dim(1), label("Employment Category")) GUIDE: axis(dim(2), label("Mean salpc")) SCALE: cat(dim(1), include("1", "2", "3")) SCALE: linear(dim(2), include(0)) ELEMENT: interval(position(jobcat*MEAN_salpc), shape.interior( shape.square)) END GPL. Regards On Thu, Dec 4, 2008 at 6:34 AM, Ortseifen, Carina < [hidden email]> wrote: > Hello! > > I am not very familar with SPSS syntax, so perhaps my question is a bit > stupid: > > Is there in SPSS for Windows 16.0 a format (value label or variable type) > similar to the percentw.d format in SAS to show numbers like 0.1 in form of > 10% in an output or the SPSS table? > > Any hints are welcome. Thanks in advance. > > Mit freundlichen Grüßen > Carina > -- > Dr. Carina Ortseifen > Abteilung Anwendungen > > Tel. (06221) 54-45 41, Fax (06221) 54-55 81 > [hidden email] > > Ruprecht-Karls-Universität Heidelberg > Universitätsrechenzentrum (URZ) > Im Neuenheimer Feld 293, 69120 Heidelberg > http://www.urz.uni-heidelberg.de > -- > 13. KSFE 2009 in Halle: www.ksfe2009.uni-halle.de > > ===================== > 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 > -- Raynald Levesque www.spsstools.net ====================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 |
| Free forum by Nabble | Edit this page |
