seeking help deleting characters from a string variable - reply to Viann, Melissa and Nirit

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

seeking help deleting characters from a string variable - reply to Viann, Melissa and Nirit

thara vardhan-2

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



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.


Reply | Threaded
Open this post in threaded view
|

Re: seeking help deleting characters from a string variable - reply to Viann, Melissa and Nirit

Jarrod Teo-2
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



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor ! ;place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.




Chat online and in real-time with friends and family! Windows Live Messenger
Reply | Threaded
Open this post in threaded view
|

Re: thanks DorraJ

thara vardhan-2

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




DorraJ Oet <[hidden email]>
Sent by: "SPSSX(r) Discussion" <[hidden email]>

29/04/2009 13:16

Please respond to
DorraJ Oet <[hidden email]>

To
[hidden email]
cc
Subject
Re: seeking help deleting characters from a string variable -              reply to Viann, Melissa and Nirit





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



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s)
only. It may contain private, confidential, copyright or legally privileged
information.  If you are not the intended recipient or you have received this
email by mistake, please reply to the author and delete this email immediately.
You must not copy, print, forward or distribute this email, nor ! ;place reliance
on its contents. This email and any attachment have been virus scanned. However,
you are requested to conduct a virus scan as well.  No liability is accepted
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not
constitute a representation by the NSW Police Force unless the author is legally
entitled to do so.




Chat online and in real-time with friends and family! Windows Live Messenger

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

All mail is subject to content scanning for possible violation of NSW Police Force
Electronic Messaging Policy. All NSW Police Force employees are required to
familiarise themselves with the content of the policy, found under Policies on the
NSW Police Force Intranet.







_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.


Reply | Threaded
Open this post in threaded view
|

Re: seeking help deleting characters from a string variable - reply to Viann, Melissa and Nirit

ViAnn Beadle
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
Sent: Tuesday, April 28, 2009 8:25 PM
To: [hidden email]
Subject: seeking help deleting characters from a string variable - reply to Viann, Melissa and Nirit

 


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


_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.

 

Reply | Threaded
Open this post in threaded view
|

Re: seeking help deleting characters from a string variable

Richard Ristow
In reply to this post by thara vardhan-2
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
Reply | Threaded
Open this post in threaded view
|

Re: seeking help deleting characters from a string variable

Oliver, Richard
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
Reply | Threaded
Open this post in threaded view
|

Re: reply to Richard Ristow - wow! seeking help deleting characters from a string variable

thara vardhan-2

Hi Richard

Thank you so much. That was a brilliant solution and it works like a dream!

many thanks
regards
thara



"Oliver, Richard" <[hidden email]>
Sent by: "SPSSX(r) Discussion" <[hidden email]>

30/04/2009 09:10

Please respond to
"Oliver, Richard" <[hidden email]>

To
[hidden email]
cc
Subject
Re: seeking help deleting characters from a string variable





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



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

All mail is subject to content scanning for possible violation of NSW Police Force
Electronic Messaging Policy. All NSW Police Force employees are required to
familiarise themselves with the content of the policy, found under Policies on the
NSW Police Force Intranet.







_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The information contained in this email is intended for the named recipient(s) 
only. It may contain private, confidential, copyright or legally privileged 
information.  If you are not the intended recipient or you have received this 
email by mistake, please reply to the author and delete this email immediately. 
You must not copy, print, forward or distribute this email, nor place reliance 
on its contents. This email and any attachment have been virus scanned. However, 
you are requested to conduct a virus scan as well.  No liability is accepted 
for any loss or damage resulting from a computer virus, or resulting from a delay
or defect in transmission of this email or any attached file. This email does not 
constitute a representation by the NSW Police Force unless the author is legally 
entitled to do so.