Delete string values according to a condition

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

Delete string values according to a condition

Mathias S.
Dear all,

I've been trying to find a way to delete certain string values of a string variable in SPSS according to a specified condition using SPSS syntax. I've got a data matrix which has the following variables

1. email address (string)
2. other string variable (string)

What I'de like to is to delete certain values of the "other string variable" if a condition is satisfied with the email adress variable.

In case the second variable would be a numeric variable the following code would work.

if ( emailaddress = "test@test.com" ) secondvariable = $sysmis.

I already tried to convert the second variable from a string to a numeric variable, however, since the second variable contains characters, the resulting variable is empty.

Do you have some advice?

Best,

Mathias
Reply | Threaded
Open this post in threaded view
|

Re: Delete string values according to a condition

Albert-Jan Roskam
Hi,

Do you mean simply:
if ( emailaddress = "[hidden email]" ) secondvariable = "".
 
Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



From: Mathias S. <[hidden email]>
To: [hidden email]
Sent: Fri, June 17, 2011 9:43:20 AM
Subject: [SPSSX-L] Delete string values according to a condition

Dear all,

I've been trying to find a way to delete certain string values of a string
variable in SPSS according to a specified condition using SPSS syntax. I've
got a data matrix which has the following variables

1. email address (string)
2. other string variable (string)

What I'de like to is to delete certain values of the "other string variable"
if a condition is satisfied with the email adress variable.

In case the second variable would be a numeric variable the following code
would work.

if ( emailaddress = "[hidden email]" ) secondvariable = $sysmis.

I already tried to convert the second variable from a string to a numeric
variable, however, since the second variable contains characters, the
resulting variable is empty.

Do you have some advice?

Best,

Mathias

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Delete-string-values-according-to-a-condition-tp4497967p4497967.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Delete string values according to a condition

Garry Gelade
In reply to this post by Mathias S.
Mathais

You cannot assign the sysmis value to a string variable.

if ( emailaddress = "[hidden email]" ) secondvariable = "".

'empties' the second variable.


Garry Gelade


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Mathias S.
Sent: 17 June 2011 08:43
To: [hidden email]
Subject: Delete string values according to a condition

Dear all,

I've been trying to find a way to delete certain string values of a string
variable in SPSS according to a specified condition using SPSS syntax. I've
got a data matrix which has the following variables

1. email address (string)
2. other string variable (string)

What I'de like to is to delete certain values of the "other string variable"
if a condition is satisfied with the email adress variable.

In case the second variable would be a numeric variable the following code
would work.

if ( emailaddress = "[hidden email]" ) secondvariable = $sysmis.

I already tried to convert the second variable from a string to a numeric
variable, however, since the second variable contains characters, the
resulting variable is empty.

Do you have some advice?

Best,

Mathias

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Delete-string-values-according
-to-a-condition-tp4497967p4497967.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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