seeking help deleting characters form a string variable

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

seeking help deleting characters form a string variable

thara vardhan-2

Dear List members

I have a variable by polregx with the following information

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.

I tried by computing a new string variable with concat function but get an error message as follows.

string region (a20).
compute region =concat (substr (polregx, 1,4)).
 
>Error # 4311 in column 45.  Text: )
>The string argument required for the function specified was not supplied.
>This command not executed.
exe.

I  tried to do it this way too but I get the same message

string fn (A20).
compute fn = concat(polregx, ' ', ' ', ' ').
 execute.

>Error # 4311 in column 43.  Text: )
>The string argument required for the function specified was not supplied.
>This command not executed.
execute.

Can any one please tell me where am I going wrong?

Many thanks

regards
Thara Vardhan
Senior Statistician
Performance Improvement & Planning



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

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 form a string variable

Lemon, John S.

If you look at the definition for CONCAT you will see it ‘adds’ strings together to create a single one. You were part way there with your first attempt, try this ( untested )

 

STRING REGION (A20)

COMPUTE REGION = SUBSTR ( polregx, 7, 20 )

 

This ‘chops out’ 20 characters from polregx, starting at the 7th character ( ‘NSW – ‘ = 6 characters )- hope this helps.

 

Best Wishes

 

John S. Lemon

DIT ( Directorate of Information Technology ) - Student Liaison Officer

University of Aberdeen

Edward Wright Building: Room G51

 

Tel:  +44 1224 273350

Fax: +44 1224 273372

 

Diary ( Free / Busy )

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Thara Vardhan
Sent: 17 April 2009 07:25
To: [hidden email]
Subject: seeking help deleting characters form a string variable

 


Dear List members

I have a variable by polregx with the following information

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.

I tried by computing a new string variable with concat function but get an error message as follows.

string region (a20).
compute region =concat (substr (polregx, 1,4)).
 
>Error # 4311 in column 45.  Text: )
>The string argument required for the function specified was not supplied.
>This command not executed.
exe.

I  tried to do it this way too but I get the same message

string fn (A20).
compute fn = concat(polregx, ' ', ' ', ' ').
 execute.

>Error # 4311 in column 43.  Text: )
>The string argument required for the function specified was not supplied.
>This command not executed.
execute.

Can any one please tell me where am I going wrong?

Many thanks

regards
Thara Vardhan
Senior Statistician
Performance Improvement & Planning


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

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.

 



The University of Aberdeen is a charity registered in Scotland, No SC013683.