|
Hi all,
I have a simple problem but have done something wrong I have a variable 'Postcode' which contains area information similar to a Zip code I think - I want to match cases to a data file which assigns postcodes to a deprivation index the variable 'Postcode' is a string and is in the form 'AB12 38G' - although it can also have a single digit before the space - 'DD4 8JH' what I am trying to do - is to trim the variable so that I have a new variable 'P_code' which in the case of the two examples provided would result in: 'AB12 3' and 'DD4 8' I tried this based on something on Raynald's site: ***************************************** STRING P_code (A6). COMPUTE P_code=RTRIM(SUBSTR(Postcode,INDEX(Postcode,' ')+1)). EXECUTE. which I thought would result in what I desired - however, what it actually delivered for the value 'AB12 38G' was '38G' what bit of syntax is wrong? I did search the archives and found some code by Jon Peck from July 2007 but it involved Python and I have no knowledge and am a bit of a syntax newbie Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ====================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 Muir,
Almost right, change your compute into: COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). To start at the first character up to the character after the space. Antoon -----Oorspronkelijk bericht----- Van: SPSSX(r) Discussion [mailto:[hidden email]] Namens Muir Houston Verzonden: dinsdag 12 februari 2008 13:38 Aan: [hidden email] Onderwerp: RTRIM mistake Hi all, I have a simple problem but have done something wrong I have a variable 'Postcode' which contains area information similar to a Zip code I think - I want to match cases to a data file which assigns postcodes to a deprivation index the variable 'Postcode' is a string and is in the form 'AB12 38G' - although it can also have a single digit before the space - 'DD4 8JH' what I am trying to do - is to trim the variable so that I have a new variable 'P_code' which in the case of the two examples provided would result in: 'AB12 3' and 'DD4 8' I tried this based on something on Raynald's site: ***************************************** STRING P_code (A6). COMPUTE P_code=RTRIM(SUBSTR(Postcode,INDEX(Postcode,' ')+1)). EXECUTE. which I thought would result in what I desired - however, what it actually delivered for the value 'AB12 38G' was '38G' what bit of syntax is wrong? I did search the archives and found some code by Jon Peck from July 2007 but it involved Python and I have no knowledge and am a bit of a syntax newbie Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 |
|
Still almost right, but I think the +1 should be -1, since I think the goal is to get everything up to, but not including the blank space.
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Antoon Smulders Sent: Tuesday, February 12, 2008 7:46 AM To: [hidden email] Subject: Re: RTRIM mistake Hello Muir, Almost right, change your compute into: COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). To start at the first character up to the character after the space. Antoon -----Oorspronkelijk bericht----- Van: SPSSX(r) Discussion [mailto:[hidden email]] Namens Muir Houston Verzonden: dinsdag 12 februari 2008 13:38 Aan: [hidden email] Onderwerp: RTRIM mistake Hi all, I have a simple problem but have done something wrong I have a variable 'Postcode' which contains area information similar to a Zip code I think - I want to match cases to a data file which assigns postcodes to a deprivation index the variable 'Postcode' is a string and is in the form 'AB12 38G' - although it can also have a single digit before the space - 'DD4 8JH' what I am trying to do - is to trim the variable so that I have a new variable 'P_code' which in the case of the two examples provided would result in: 'AB12 3' and 'DD4 8' I tried this based on something on Raynald's site: ***************************************** STRING P_code (A6). COMPUTE P_code=RTRIM(SUBSTR(Postcode,INDEX(Postcode,' ')+1)). EXECUTE. which I thought would result in what I desired - however, what it actually delivered for the value 'AB12 38G' was '38G' what bit of syntax is wrong? I did search the archives and found some code by Jon Peck from July 2007 but it involved Python and I have no knowledge and am a bit of a syntax newbie Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 Muir Houston
Oops. Never mind. +1 is correct if the goal is capture everything up to the space and including the next character after the space.
-----Original Message----- From: Oliver, Richard Sent: Tuesday, February 12, 2008 9:05 AM To: '[hidden email]'; [hidden email] Subject: RE: Re: RTRIM mistake Still almost right, but I think the +1 should be -1, since I think the goal is to get everything up to, but not including the blank space. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Antoon Smulders Sent: Tuesday, February 12, 2008 7:46 AM To: [hidden email] Subject: Re: RTRIM mistake Hello Muir, Almost right, change your compute into: COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). To start at the first character up to the character after the space. Antoon -----Oorspronkelijk bericht----- Van: SPSSX(r) Discussion [mailto:[hidden email]] Namens Muir Houston Verzonden: dinsdag 12 februari 2008 13:38 Aan: [hidden email] Onderwerp: RTRIM mistake Hi all, I have a simple problem but have done something wrong I have a variable 'Postcode' which contains area information similar to a Zip code I think - I want to match cases to a data file which assigns postcodes to a deprivation index the variable 'Postcode' is a string and is in the form 'AB12 38G' - although it can also have a single digit before the space - 'DD4 8JH' what I am trying to do - is to trim the variable so that I have a new variable 'P_code' which in the case of the two examples provided would result in: 'AB12 3' and 'DD4 8' I tried this based on something on Raynald's site: ***************************************** STRING P_code (A6). COMPUTE P_code=RTRIM(SUBSTR(Postcode,INDEX(Postcode,' ')+1)). EXECUTE. which I thought would result in what I desired - however, what it actually delivered for the value 'AB12 38G' was '38G' what bit of syntax is wrong? I did search the archives and found some code by Jon Peck from July 2007 but it involved Python and I have no knowledge and am a bit of a syntax newbie Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 |
|
Hi Richard and listers
I tried Anton's suggestion COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). and it generated this error code >Error # 4309 in column 256. Text: (End of Command) >Invalid combination of data types in an assignment. Character strings may >only be assigned to string variables. Numeric and logical quantities may >only be assigned to numeric variables. Consider using the STRING or NUMBER >function. >This command not executed. so till not sure - yes I want one digit after the blank thanks Muir Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 ________________________________ From: SPSSX(r) Discussion on behalf of Oliver, Richard Sent: Tue 12/02/2008 15:27 To: [hidden email] Subject: Re: RTRIM mistake Oops. Never mind. +1 is correct if the goal is capture everything up to the space and including the next character after the space. -----Original Message----- From: Oliver, Richard Sent: Tuesday, February 12, 2008 9:05 AM To: '[hidden email]'; [hidden email] Subject: RE: Re: RTRIM mistake Still almost right, but I think the +1 should be -1, since I think the goal is to get everything up to, but not including the blank space. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Antoon Smulders Sent: Tuesday, February 12, 2008 7:46 AM To: [hidden email] Subject: Re: RTRIM mistake Hello Muir, Almost right, change your compute into: COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). To start at the first character up to the character after the space. Antoon -----Oorspronkelijk bericht----- Van: SPSSX(r) Discussion [mailto:[hidden email]] Namens Muir Houston Verzonden: dinsdag 12 februari 2008 13:38 Aan: [hidden email] Onderwerp: RTRIM mistake Hi all, I have a simple problem but have done something wrong I have a variable 'Postcode' which contains area information similar to a Zip code I think - I want to match cases to a data file which assigns postcodes to a deprivation index the variable 'Postcode' is a string and is in the form 'AB12 38G' - although it can also have a single digit before the space - 'DD4 8JH' what I am trying to do - is to trim the variable so that I have a new variable 'P_code' which in the case of the two examples provided would result in: 'AB12 3' and 'DD4 8' I tried this based on something on Raynald's site: ***************************************** STRING P_code (A6). COMPUTE P_code=RTRIM(SUBSTR(Postcode,INDEX(Postcode,' ')+1)). EXECUTE. which I thought would result in what I desired - however, what it actually delivered for the value 'AB12 38G' was '38G' what bit of syntax is wrong? I did search the archives and found some code by Jon Peck from July 2007 but it involved Python and I have no knowledge and am a bit of a syntax newbie Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ====================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 |
|
Your original syntax started with
STRING P_code (A6). did you delete this variable or forget to run this command? COMPUTE assumes a numeric variable (unless otherwise instructed by STRING ) --jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Muir Houston Sent: Tuesday, February 12, 2008 9:36 AM To: [hidden email] Subject: Re: RTRIM mistake Hi Richard and listers I tried Anton's suggestion COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). and it generated this error code >Error # 4309 in column 256. Text: (End of Command) >Invalid combination of data types in an assignment. Character strings >may >only be assigned to string variables. Numeric and logical quantities >may >only be assigned to numeric variables. Consider using the STRING or >NUMBER >function. >This command not executed. so till not sure - yes I want one digit after the blank thanks Muir Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 ________________________________ From: SPSSX(r) Discussion on behalf of Oliver, Richard Sent: Tue 12/02/2008 15:27 To: [hidden email] Subject: Re: RTRIM mistake Oops. Never mind. +1 is correct if the goal is capture everything up to the space and including the next character after the space. -----Original Message----- From: Oliver, Richard Sent: Tuesday, February 12, 2008 9:05 AM To: '[hidden email]'; [hidden email] Subject: RE: Re: RTRIM mistake Still almost right, but I think the +1 should be -1, since I think the goal is to get everything up to, but not including the blank space. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Antoon Smulders Sent: Tuesday, February 12, 2008 7:46 AM To: [hidden email] Subject: Re: RTRIM mistake Hello Muir, Almost right, change your compute into: COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). To start at the first character up to the character after the space. Antoon -----Oorspronkelijk bericht----- Van: SPSSX(r) Discussion [mailto:[hidden email]] Namens Muir Houston Verzonden: dinsdag 12 februari 2008 13:38 Aan: [hidden email] Onderwerp: RTRIM mistake Hi all, I have a simple problem but have done something wrong I have a variable 'Postcode' which contains area information similar to a Zip code I think - I want to match cases to a data file which assigns postcodes to a deprivation index the variable 'Postcode' is a string and is in the form 'AB12 38G' - although it can also have a single digit before the space - 'DD4 8JH' what I am trying to do - is to trim the variable so that I have a new variable 'P_code' which in the case of the two examples provided would result in: 'AB12 3' and 'DD4 8' I tried this based on something on Raynald's site: ***************************************** STRING P_code (A6). COMPUTE P_code=RTRIM(SUBSTR(Postcode,INDEX(Postcode,' ')+1)). EXECUTE. which I thought would result in what I desired - however, what it actually delivered for the value 'AB12 38G' was '38G' what bit of syntax is wrong? I did search the archives and found some code by Jon Peck from July 2007 but it involved Python and I have no knowledge and am a bit of a syntax newbie Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 |
|
Thanks Jim - I had forgotten the STRING P_code (A6).
Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 ________________________________ From: SPSSX(r) Discussion on behalf of Marks, Jim Sent: Tue 12/02/2008 15:51 To: [hidden email] Subject: Re: RTRIM mistake Your original syntax started with STRING P_code (A6). did you delete this variable or forget to run this command? COMPUTE assumes a numeric variable (unless otherwise instructed by STRING ) --jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Muir Houston Sent: Tuesday, February 12, 2008 9:36 AM To: [hidden email] Subject: Re: RTRIM mistake Hi Richard and listers I tried Anton's suggestion COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). and it generated this error code >Error # 4309 in column 256. Text: (End of Command) >Invalid combination of data types in an assignment. Character strings >may >only be assigned to string variables. Numeric and logical quantities >may >only be assigned to numeric variables. Consider using the STRING or >NUMBER >function. >This command not executed. so till not sure - yes I want one digit after the blank thanks Muir Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 ________________________________ From: SPSSX(r) Discussion on behalf of Oliver, Richard Sent: Tue 12/02/2008 15:27 To: [hidden email] Subject: Re: RTRIM mistake Oops. Never mind. +1 is correct if the goal is capture everything up to the space and including the next character after the space. -----Original Message----- From: Oliver, Richard Sent: Tuesday, February 12, 2008 9:05 AM To: '[hidden email]'; [hidden email] Subject: RE: Re: RTRIM mistake Still almost right, but I think the +1 should be -1, since I think the goal is to get everything up to, but not including the blank space. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Antoon Smulders Sent: Tuesday, February 12, 2008 7:46 AM To: [hidden email] Subject: Re: RTRIM mistake Hello Muir, Almost right, change your compute into: COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). To start at the first character up to the character after the space. Antoon -----Oorspronkelijk bericht----- Van: SPSSX(r) Discussion [mailto:[hidden email]] Namens Muir Houston Verzonden: dinsdag 12 februari 2008 13:38 Aan: [hidden email] Onderwerp: RTRIM mistake Hi all, I have a simple problem but have done something wrong I have a variable 'Postcode' which contains area information similar to a Zip code I think - I want to match cases to a data file which assigns postcodes to a deprivation index the variable 'Postcode' is a string and is in the form 'AB12 38G' - although it can also have a single digit before the space - 'DD4 8JH' what I am trying to do - is to trim the variable so that I have a new variable 'P_code' which in the case of the two examples provided would result in: 'AB12 3' and 'DD4 8' I tried this based on something on Raynald's site: ***************************************** STRING P_code (A6). COMPUTE P_code=RTRIM(SUBSTR(Postcode,INDEX(Postcode,' ')+1)). EXECUTE. which I thought would result in what I desired - however, what it actually delivered for the value 'AB12 38G' was '38G' what bit of syntax is wrong? I did search the archives and found some code by Jon Peck from July 2007 but it involved Python and I have no knowledge and am a bit of a syntax newbie Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ====================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 Oliver, Richard
Hi Muir.
Did you run the line STRING P_code (A6). in your original code? Greetings -----Oorspronkelijk bericht----- Van: SPSSX(r) Discussion [mailto:[hidden email]] Namens Muir Houston Verzonden: dinsdag 12 februari 2008 16:36 Aan: [hidden email] Onderwerp: Re: RTRIM mistake Hi Richard and listers I tried Anton's suggestion COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). and it generated this error code >Error # 4309 in column 256. Text: (End of Command) >Invalid combination of data types in an assignment. Character strings may >only be assigned to string variables. Numeric and logical quantities may >only be assigned to numeric variables. Consider using the STRING or NUMBER >function. >This command not executed. so till not sure - yes I want one digit after the blank thanks Muir Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 ________________________________ From: SPSSX(r) Discussion on behalf of Oliver, Richard Sent: Tue 12/02/2008 15:27 To: [hidden email] Subject: Re: RTRIM mistake Oops. Never mind. +1 is correct if the goal is capture everything up to the space and including the next character after the space. -----Original Message----- From: Oliver, Richard Sent: Tuesday, February 12, 2008 9:05 AM To: '[hidden email]'; [hidden email] Subject: RE: Re: RTRIM mistake Still almost right, but I think the +1 should be -1, since I think the goal is to get everything up to, but not including the blank space. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Antoon Smulders Sent: Tuesday, February 12, 2008 7:46 AM To: [hidden email] Subject: Re: RTRIM mistake Hello Muir, Almost right, change your compute into: COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). To start at the first character up to the character after the space. Antoon -----Oorspronkelijk bericht----- Van: SPSSX(r) Discussion [mailto:[hidden email]] Namens Muir Houston Verzonden: dinsdag 12 februari 2008 13:38 Aan: [hidden email] Onderwerp: RTRIM mistake Hi all, I have a simple problem but have done something wrong I have a variable 'Postcode' which contains area information similar to a Zip code I think - I want to match cases to a data file which assigns postcodes to a deprivation index the variable 'Postcode' is a string and is in the form 'AB12 38G' - although it can also have a single digit before the space - 'DD4 8JH' what I am trying to do - is to trim the variable so that I have a new variable 'P_code' which in the case of the two examples provided would result in: 'AB12 3' and 'DD4 8' I tried this based on something on Raynald's site: ***************************************** STRING P_code (A6). COMPUTE P_code=RTRIM(SUBSTR(Postcode,INDEX(Postcode,' ')+1)). EXECUTE. which I thought would result in what I desired - however, what it actually delivered for the value 'AB12 38G' was '38G' what bit of syntax is wrong? I did search the archives and found some code by Jon Peck from July 2007 but it involved Python and I have no knowledge and am a bit of a syntax newbie Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 Muir Houston
Did you include the STRING command declaring the new string variable P_code prior to the COMPUTE command? The following example seems to work:
data list free /postcode (a8). begin data "AB12 38G" end data. STRING P_code (a6). COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). LIST. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Muir Houston Sent: Tuesday, February 12, 2008 9:36 AM To: [hidden email] Subject: Re: RTRIM mistake Hi Richard and listers I tried Anton's suggestion COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). and it generated this error code >Error # 4309 in column 256. Text: (End of Command) >Invalid combination of data types in an assignment. Character strings may >only be assigned to string variables. Numeric and logical quantities may >only be assigned to numeric variables. Consider using the STRING or NUMBER >function. >This command not executed. so till not sure - yes I want one digit after the blank thanks Muir Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 ________________________________ From: SPSSX(r) Discussion on behalf of Oliver, Richard Sent: Tue 12/02/2008 15:27 To: [hidden email] Subject: Re: RTRIM mistake Oops. Never mind. +1 is correct if the goal is capture everything up to the space and including the next character after the space. -----Original Message----- From: Oliver, Richard Sent: Tuesday, February 12, 2008 9:05 AM To: '[hidden email]'; [hidden email] Subject: RE: Re: RTRIM mistake Still almost right, but I think the +1 should be -1, since I think the goal is to get everything up to, but not including the blank space. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Antoon Smulders Sent: Tuesday, February 12, 2008 7:46 AM To: [hidden email] Subject: Re: RTRIM mistake Hello Muir, Almost right, change your compute into: COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). To start at the first character up to the character after the space. Antoon -----Oorspronkelijk bericht----- Van: SPSSX(r) Discussion [mailto:[hidden email]] Namens Muir Houston Verzonden: dinsdag 12 februari 2008 13:38 Aan: [hidden email] Onderwerp: RTRIM mistake Hi all, I have a simple problem but have done something wrong I have a variable 'Postcode' which contains area information similar to a Zip code I think - I want to match cases to a data file which assigns postcodes to a deprivation index the variable 'Postcode' is a string and is in the form 'AB12 38G' - although it can also have a single digit before the space - 'DD4 8JH' what I am trying to do - is to trim the variable so that I have a new variable 'P_code' which in the case of the two examples provided would result in: 'AB12 3' and 'DD4 8' I tried this based on something on Raynald's site: ***************************************** STRING P_code (A6). COMPUTE P_code=RTRIM(SUBSTR(Postcode,INDEX(Postcode,' ')+1)). EXECUTE. which I thought would result in what I desired - however, what it actually delivered for the value 'AB12 38G' was '38G' what bit of syntax is wrong? I did search the archives and found some code by Jon Peck from July 2007 but it involved Python and I have no knowledge and am a bit of a syntax newbie Muir Houston Research Fellow CRLL Institute of Education University of Stirling FK9 4LA 01786-46-7615 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 -- The University of Stirling is a university established in Scotland by charter at Stirling, FK9 4LA. Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not disclose, copy or deliver this message to anyone and any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. ======= 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 Antoon Smulders
>>The variable 'Postcode' is a string and is in the form 'AB12 38G' -
>>although it can also have a single digit before the space - 'DD4 >>8JH'. I [need] to trim the variable so that I have a new variable >>'P_code' which in the case of the two examples provided would >>result in: 'AB12 3' and 'DD4 8' At 08:45 AM 2/12/2008, Antoon Smulders wrote, solving the problem: >COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). > >To start at the first character up to the character after the space. Addendum: The RTRIM is not needed, and has no effect here. RTRIM removes trailing blanks; but when the result is assigned to a string variable, it's re-padded with trailing blanks, to the length of the string variable. If there's 'Postcode' values can come in with leading blanks, you may want LTRIM: COMPUTE P_code=LTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). ===================== 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 |
|
Richard,
Perspicacious, as usual. Thanks! King Richard Ristow <[hidden email]> wrote: >>The variable 'Postcode' is a string and is in the form 'AB12 38G' - >>although it can also have a single digit before the space - 'DD4 >>8JH'. I [need] to trim the variable so that I have a new variable >>'P_code' which in the case of the two examples provided would >>result in: 'AB12 3' and 'DD4 8' At 08:45 AM 2/12/2008, Antoon Smulders wrote, solving the problem: >COMPUTE P_code=RTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). > >To start at the first character up to the character after the space. Addendum: The RTRIM is not needed, and has no effect here. RTRIM removes trailing blanks; but when the result is assigned to a string variable, it's re-padded with trailing blanks, to the length of the string variable. If there's 'Postcode' values can come in with leading blanks, you may want LTRIM: COMPUTE P_code=LTRIM(SUBSTR(Postcode,1, INDEX(Postcode,' ')+1)). ===================== 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 |
| Free forum by Nabble | Edit this page |
