Substring question

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

Substring question

Stefan Keydel
Hello,

I'm trying to recode a variable that holds an email address so that the
new variable begins at the  '@' symbol and includes everything to its
right. I've tried to use the Compute Variable procedure under the
Transform menu, but I'm getting an error. Here are the steps I've taken:

Note: 'email' is the string variable that holds the original email
address.

1. Create target variable 'domain' (string variable with a width of 25)
2. Open Compute Variable dialogue, enter 'domain' into the Target
Variable field, and set the following as the expression:
        =SUBSTR(email,@)
 3. When I click on 'OK', I get the following error message:

"Incorrect variable name: either the name is more than 8 characters, or
it is not defined by a previous command"

Any clue as to why this isn't working? Is there a another way to
accomplish what I'm trying to do?

Thanks,

Stefan

Configuration: SPSS 11.0.4 for Mac OS X
Reply | Threaded
Open this post in threaded view
|

Re: Substring question

San K
Here is the Syntax solution.

STRING domain (A25).

COMPUTE domain = SUBSTR(email, (INDEX (email, '@') + 1) ).

EXECUTE.

- San

On 12/1/06, Stefan Keydel <[hidden email]> wrote:

>
> Hello,
>
> I'm trying to recode a variable that holds an email address so that the
> new variable begins at the  '@' symbol and includes everything to its
> right. I've tried to use the Compute Variable procedure under the
> Transform menu, but I'm getting an error. Here are the steps I've taken:
>
> Note: 'email' is the string variable that holds the original email
> address.
>
> 1. Create target variable 'domain' (string variable with a width of 25)
> 2. Open Compute Variable dialogue, enter 'domain' into the Target
> Variable field, and set the following as the expression:
>        =SUBSTR(email,@)
> 3. When I click on 'OK', I get the following error message:
>
> "Incorrect variable name: either the name is more than 8 characters, or
> it is not defined by a previous command"
>
> Any clue as to why this isn't working? Is there a another way to
> accomplish what I'm trying to do?
>
> Thanks,
>
> Stefan
>
> Configuration: SPSS 11.0.4 for Mac OS X
>