Trimming a string variable

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

Trimming a string variable

Allen Frommelt
I have a 11 character string  variable that is essentially a social security number with E or S tacked on the end to identify whether the participant is a employee or spouse.  I would like to create a new variable relationship that only has the E or S and remove the social security number from the identifier.  I tried using the substr command, but couldn't get it to work.

Thanks,

Allen



________________________________
This email and all attachments are confidential and intended solely
for the use of the individual or entity to which they are addressed.
If you have received this email in error please notify the sender
by replying to this message. If you are not the intended recipient,
please delete this message and all attachments immediately. Do not
copy, disclose, use or act upon the information contained. Please
note that any views or opinions presented in this email are solely
those of the author and do not necessarily represent those of the
company. Finally, the recipient should check this email and any
attachments for the presence of viruses. While every attempt is made
to verify that the contents are safe, the company accepts no liability
for any damage caused by any virus transmitted by this email.

====================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: Trimming a string variable

Maguin, Eugene
Allen,

String relationship(a1).
Compute relationship=substr(xxxx,11,1).

Where xxxx is your original variable.


Gene Maguin



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Allen Frommelt
Sent: Monday, September 29, 2008 2:23 PM
To: [hidden email]
Subject: Trimming a string variable


I have a 11 character string  variable that is essentially a social security
number with E or S tacked on the end to identify whether the participant is
a employee or spouse.  I would like to create a new variable relationship
that only has the E or S and remove the social security number from the
identifier.  I tried using the substr command, but couldn't get it to work.

Thanks,

Allen



________________________________
This email and all attachments are confidential and intended solely
for the use of the individual or entity to which they are addressed.
If you have received this email in error please notify the sender
by replying to this message. If you are not the intended recipient,
please delete this message and all attachments immediately. Do not
copy, disclose, use or act upon the information contained. Please
note that any views or opinions presented in this email are solely
those of the author and do not necessarily represent those of the
company. Finally, the recipient should check this email and any
attachments for the presence of viruses. While every attempt is made
to verify that the contents are safe, the company accepts no liability
for any damage caused by any virus transmitted by this email.

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

Re: Trimming a string variable

Richard Ristow
In reply to this post by Allen Frommelt
At 02:23 PM 9/29/2008, Allen Frommelt wrote:

>I have a 11 character string  variable that is essentially a social
>security number with E or S tacked on the end.  I would like to
>create a new variable 'relationship' that only has the E or S.

>I tried using the substr command, but couldn't get it to work.

Unfortunately, "couldn't get it to work" isn't easy to work with: We
don't know what your SUBSTRING call was (it's a function, not a
command, by the way), and we don't know what you got, instead of what
you wanted. Or whether you got any error messages.

The 11th character of string 'ID' should be (not tested)

SUBSTR(ID,11,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
Reply | Threaded
Open this post in threaded view
|

Re: Trimming a string variable

Fry, Jonathan B.
In reply to this post by Allen Frommelt
A social security number is nine digits, not ten.  Unless there is something else there,

substr(id,10,1)

will get the last character.
------
Jonathan Fry

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Allen Frommelt
Sent: Monday, September 29, 2008 1:23 PM
To: [hidden email]
Subject: Trimming a string variable

I have a 11 character string  variable that is essentially a social security number with E or S tacked on the end to identify whether the participant is a employee or spouse.  I would like to create a new variable relationship that only has the E or S and remove the social security number from the identifier.  I tried using the substr command, but couldn't get it to work.

Thanks,

Allen



________________________________
This email and all attachments are confidential and intended solely
for the use of the individual or entity to which they are addressed.
If you have received this email in error please notify the sender
by replying to this message. If you are not the intended recipient,
please delete this message and all attachments immediately. Do not
copy, disclose, use or act upon the information contained. Please
note that any views or opinions presented in this email are solely
those of the author and do not necessarily represent those of the
company. Finally, the recipient should check this email and any
attachments for the presence of viruses. While every attempt is made
to verify that the contents are safe, the company accepts no liability
for any damage caused by any virus transmitted by this email.

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

Re: Trimming a string variable

Allen Frommelt
In reply to this post by Maguin, Eugene
Thanks, Gene!  That produced exactly the result that I needed.--Allen

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin
Sent: Monday, September 29, 2008 4:23 PM
To: [hidden email]
Subject: Re: Trimming a string variable

Allen,

String relationship(a1).
Compute relationship=substr(xxxx,11,1).

Where xxxx is your original variable.


Gene Maguin



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Allen Frommelt
Sent: Monday, September 29, 2008 2:23 PM
To: [hidden email]
Subject: Trimming a string variable


I have a 11 character string  variable that is essentially a social security
number with E or S tacked on the end to identify whether the participant is
a employee or spouse.  I would like to create a new variable relationship
that only has the E or S and remove the social security number from the
identifier.  I tried using the substr command, but couldn't get it to work.

Thanks,

Allen



________________________________
This email and all attachments are confidential and intended solely
for the use of the individual or entity to which they are addressed.
If you have received this email in error please notify the sender
by replying to this message. If you are not the intended recipient,
please delete this message and all attachments immediately. Do not
copy, disclose, use or act upon the information contained. Please
note that any views or opinions presented in this email are solely
those of the author and do not necessarily represent those of the
company. Finally, the recipient should check this email and any
attachments for the presence of viruses. While every attempt is made
to verify that the contents are safe, the company accepts no liability
for any damage caused by any virus transmitted by this email.

=======
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

This email and all attachments are confidential and intended solely
for the use of the individual or entity to which they are addressed.
If you have received this email in error please notify the sender
by replying to this message. If you are not the intended recipient,
please delete this message and all attachments immediately.  Do not
copy, disclose, use or act upon the information contained. Please
note that any views or opinions presented in this email are solely
those of the author and do not necessarily represent those of the
company. Finally, the recipient should check this email and any
attachments for the presence of viruses. While every attempt is made
to verify that the contents are safe, the company accepts no liability
for any damage caused by any virus transmitted by this email.

=====================
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