|
Hi Viann, Melissa and Nirit Thank you for replying to my earlier email seeking help with deleting characters from a string variable. I was of f sick for a while and have resumed work only today. Hence I could not work on my syntax problem. My question: polregx NSW - Ashfield NSW - Eastern Beaches NSW - Bankstown NSW - Blue Mountains NSW - Brisbane Water I want to remove the first 3 letters and the - for instance NSW-Eastern Beaches should read as only Eastern beaches. As pointed out by all of you I added the period after string region (A20). But I still get an error message. However today I have run the syntax as follows: STRING REGION (A20). COMPUTE REGION = SUBSTR (polregx, 7, 20). Exe. I get the following message Error # 4311 in column 40. Text: ) The string argument required for the function specified was not supplied. This command not executed. Exe. More importantly I have checked the variable polregx and it is defined as numeric with value labels. Hence I tried this as an alternative however i still get the same error message. Numeric region (N20). compute region =NUMBER(substr(polregx,7,20),F20). >Error # 4311 in column 43. Text: ) >The string argument required for the function specified was not supplied. >This command not executed. execute. Can you help me please? thanks regards thara Thara Vardhan Senior Statistician Performance Improvement & Planning NSW Police Tel: (02) 8835-8526
|
|
Hi thara,
You mentioned that "More importantly I have checked the variable polregx and it is defined as numeric with value labels" Number 1 This means that the following syntax cannot work. STRING REGION (A20). COMPUTE REGION = SUBSTR (polregx, 7, 20). Exe. reason: substr is meant for string variables only and it is use to shorten the length of a string variable. Number 2 The following syntax cannot work as well. Numeric region (N20). compute region =NUMBER(substr(polregx,7,20),F20). Reason: This is because,
You should be now more concern on changing the value label of polregx instead. example 1 in polregx is labeled as NSW - Ashfield , it should be changed to Ashfield. This can be done easily in the variable view of SPSS Editor Window. Cheers Dorraj Date: Wed, 29 Apr 2009 12:24:43 +1000 From: [hidden email] Subject: seeking help deleting characters from a string variable - reply to Viann, Melissa and Nirit To: [hidden email] Hi Viann, Melissa and Nirit Thank you for replying to my earlier email seeking help with deleting characters from a string variable. I was of f sick for a while and have resumed work only today. Hence I could not work on my syntax problem. My question: polregx NSW - Ashfield NSW - Eastern Beaches NSW - Bankstown NSW - Blue Mountains NSW - Brisbane Water I! want to remove the first 3 letters and the - for instance NSW-Eastern Beaches should read as only Eastern beaches. As pointed out by all of you I added the period after string region (A20). But I still get an error message. However today I have run the syntax as follows: STRING REGION (A20). COMPUTE REGION = SUBSTR (polregx, 7, 20). Exe. I get the following message Error # 4311 in column 40. Text: ) The string argument required for the function specified was not supplied. This command not executed. Exe. More importantly I have checked the variable polregx and it is defined as numeric with value labels. Hence I tried this as an alternative however i still get the same error message. Numeric region (N20). compute region =NUMBER(substr(polregx,7,20),F20). >Error # 4311 in column 43. Text: ) >The string argument required for the function specified was not supplied. >This command not executed. execute. Can you help me please? thanks regards thara Thara Vardhan Senior Statistician Performance Improvement & Planning NSW PoliceTel: (02) 8835-8526
Chat online and in real-time with friends and family! Windows Live Messenger |
|
Hi Dorra Thanks for your response. Indeed soon after I sent my mail to Melissa and all I realised that what I am looking for is to change the value labels. This is what I am doing now using SPSS syntax editor. Thank you once again. regards Thara Vardhan
Hi thara, You mentioned that "More importantly I have checked the variable polregx and it is defined as numeric with value labels" Number 1 This means that the following syntax cannot work. STRING REGION (A20). COMPUTE REGION = SUBSTR (polregx, 7, 20). Exe. reason: substr is meant for string variables only and it is use to shorten the length of a string variable. Number 2 The following syntax cannot work as well. Numeric region (N20). compute region =NUMBER(substr(polregx,7,20),F20). Reason: This is because, 1. numeric region declare a numerical variable region but the format should be (f20) not (n20). 2. number is used to convert a string variable to a numeric variable it is not applicable on your polregx. You should be now more concern on changing the value label of polregx instead. example 1 in polregx is labeled as NSW - Ashfield , it should be changed to Ashfield. This can be done easily in the variable view of SPSS Editor Window. Cheers Dorraj Date: Wed, 29 Apr 2009 12:24:43 +1000 From: [hidden email] Subject: seeking help deleting characters from a string variable - reply to Viann, Melissa and Nirit To: [hidden email] Hi Viann, Melissa and Nirit Thank you for replying to my earlier email seeking help with deleting characters from a string variable. I was of f sick for a while and have resumed work only today. Hence I could not work on my syntax problem. My question: polregx NSW - Ashfield NSW - Eastern Beaches NSW - Bankstown NSW - Blue Mountains NSW - Brisbane Water I! want to remove the first 3 letters and the - for instance NSW-Eastern Beaches should read as only Eastern beaches. As pointed out by all of you I added the period after string region (A20). But I still get an error message. However today I have run the syntax as follows: STRING REGION (A20). COMPUTE REGION = SUBSTR (polregx, 7, 20). Exe. I get the following message Error # 4311 in column 40. Text: ) The string argument required for the function specified was not supplied. This command not executed. Exe. More importantly I have checked the variable polregx and it is defined as numeric with value labels. Hence I tried this as an alternative however i still get the same error message. Numeric region (N20). compute region =NUMBER(substr(polregx,7,20),F20). >Error # 4311 in column 43. Text: ) >The string argument required for the function specified was not supplied. >This command not executed. execute. Can you help me please? thanks regards thara Thara Vardhan Senior Statistician Performance Improvement & Planning NSW PoliceTel: (02) 8835-8526
Chat online and in real-time with friends and family! Windows Live Messenger
|
|
In reply to this post by thara vardhan-2
SUBSTR works on string variables but polregx is a numeric variable
with value labels. What you need to do is change the value labels. Now
typically you would do this with a VALUE LABELS command. If you have a few of
these, it’s probably easier to just use a value labels command. If you
have many of them you have to go around the barn by using the VALUELABEL
function to compute a new variable whose values are the contents of the value
labels. Then you need to work on that new variable using the SUBSTR function. So something like this should work: STRING newpolregx (A??). COMPUTE newpolregx = VALUELABEL(polregx). STRING trimmedpolreqx (A??). COMPUTE trimmedpolregx = SUBSTR(newpolregx, ?, ?). Change the question marks to the actual lengths you’re
dealing with. They would be the maximum length of the longest label, the
maximum length of the variable after trimming, and the actual character
positions to trim. Now somebody defined these labels in the 1st place. In
the future it would probably just be easier for whoever defined them to provide
you with the set you want. From: SPSSX(r) Discussion
[mailto:[hidden email]] On Behalf Of Thara Vardhan
|
|
In reply to this post by thara vardhan-2
At 10:24 PM 4/28/2009, Thara Vardhan wrote:
polregx Ah, hah! So you probably want this (untested): STRING REGION (A20). compute region = substr(VALUELABEL(polregx),7,20). (You don't need those "EXE." statements.) ===================== 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 |
|
Whoa. Cool. That should work. From: SPSSX(r) Discussion on behalf of Richard Ristow Sent: Wed 4/29/2009 5:50 PM To: [hidden email] Subject: Re: seeking help deleting characters from a string variable At 10:24 PM 4/28/2009, Thara Vardhan wrote:
polregx Ah, hah! So you probably want this (untested): STRING REGION (A20). compute region = substr(VALUELABEL(polregx),7,20). (You don't need those "EXE." statements.) ===================== 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 Thank you so much. That was a brilliant solution and it works like a dream! many thanks regards thara
Whoa. Cool. That should work. From: SPSSX(r) Discussion on behalf of Richard Ristow Sent: Wed 4/29/2009 5:50 PM To: [hidden email] Subject: Re: seeking help deleting characters from a string variable At 10:24 PM 4/28/2009, Thara Vardhan wrote: polregx NSW - Ashfield NSW - Eastern Beaches I want to remove the first 3 letters and the - for instance "NSW-Eastern Beaches" should read as only "Eastern beaches". [I corrected the syntax error in the STRING command.] Today I have run the syntax as follows: STRING REGION (A20). COMPUTE REGION = SUBSTR (polregx, 7, 20). I get the message "Error # 4311 ... The string argument required for the function specified was not supplied." I have checked the variable polregx and it is numeric with value labels. Ah, hah! So you probably want this (untested): STRING REGION (A20). compute region = substr(VALUELABEL(polregx),7,20). (You don't need those "EXE." statements.) ===================== 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 |
