Re: seeking help deleting characters from a string variable - thank you once again DorraJ and Viann

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: seeking help deleting characters from a string variable - thank you once again DorraJ and Viann

thara vardhan-2

Hi Dorra

Thank you once again for sending me the quickest options for creating value label syntax. I am experienced in doing that. The fastest way would be to get a  frequencies on polregx and copy paste the output table - remove the unwanted text,  put the ' ' and run it in a syntax file.

This way it is also permanently available on file.

I have done it now.  

Viann - thanks a lot once again for the options you have suggested. The last one was the best - that is to let my data provider know about my exact  requirements. I have already done that and he has agreed to sent it to me.

thanks
regards
Thara Vardhan
Senior Statistician
Performance Improvement & Planning
NSW Police
Tel: (02) 8835-8526



DorraJ Oet <[hidden email]>

29/04/2009 13:36

To
<[hidden email]>
cc
Subject
RE: thanks DorraJ





Hi Thara,

To make your life easier, you might want to explore value label command.

Example:


val lab v1 '1' 'abc'

'2' "It's mine"

'3' 'ok then'.

Do take note that the labelling will be given to 1, 2 and 3 in your data only. The rest of the labels will be deleted.

Take note of the labelling done for 2 because of the it's you will need a double quotation instead of a single quote.

The full stop is at the last value label that you want to do, in my case, value 3 after 'ok then'.

A shorter way


If you have a variable dictionary given for your
polregx normally given in excel telling you what are the value labels on the values, example

In Excel


1 abc
2 It's Mine
3 Ok then


Just


1.        Copy and paste it into the syntax window.
2.        add in all the quotes and the full stop
 
'1' 'abc'

'2' "It's mine"

'3' 'ok then'.

Then add the command and the variable on the first value.

val lab v1 '1' 'abc'

'2' "It's mine"

'3' 'ok then'.

I hope you understand what I mean. Try it out. This is much faster.

Have fun.

Cheers
Dorraj


Date: Wed, 29 Apr 2009 13:23:18 +1000
From: [hidden email]
Subject: Re: thanks DorraJ
To: [hidden email]


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.




See all the ways you can stay connected to friends and family

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

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.