SPSS String Trouble

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

SPSS String Trouble

Sarah T
Hi all,

I'm having trouble with some data manipulation. I have several string variables in my dataset. For many cases, the data takes on the form of "Other: abcdefg". I'd like to delete everything after 'Other', so any response starting with 'Other' only include that information (not the 'abcdefg').

I'm trying to do this with an RTRIM function, but I can't get it to work.

I first tried-

string newvar (a200).
COMPUTE newvar=rtrim(oldvar,"Other").
exe.


However, the error message that I'm getting and what I am reading seems to suggest that what I want to trim after must be just 1 character.

I can't use the ":" after 'Other' as there are some responses in my dataset that actually include ":" and I want to keep those. (for example, there may be responses like "blah blah: blah" that aren't preceded by 'Other' and thus I want to keep.

Help!
Reply | Threaded
Open this post in threaded view
|

Re: SPSS String Trouble

Sarah T
Hi all,

I actually figured it out-- using 'other' as my 'index'-- thanks to Raynald's great spss tools page. Now to figure out how to quickly loop this through all of my variables.

Sarah
Reply | Threaded
Open this post in threaded view
|

Re: SPSS String Trouble

David Marso
Administrator
Yes INDEX is likely the most effective approach.
"Now to figure out how to quickly loop this through all of my variables"
See DO REPEAT .

Sarah T wrote
Hi all,

I actually figured it out-- using 'other' as my 'index'-- thanks to Raynald's great spss tools page. Now to figure out how to quickly loop this through all of my variables.

Sarah
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: SPSS String Trouble

John F Hall
Without knowing exactly what your data represent, my initial reaction is to
ask why you are using string variables?  SPSS works much more quickly with
numeric variables and you can always use the variable and value labels for
your "strings".


John F Hall (Mr)
[retired academic survey researcher]

Email:    [hidden email]
Website: www.surveyresearch.weebly.com




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
David Marso
Sent: 07 January 2013 07:33
To: [hidden email]
Subject: Re: SPSS String Trouble

Yes INDEX is likely the most effective approach.
"Now to figure out how to quickly loop this through all of my variables"
See DO REPEAT .


Sarah T wrote
> Hi all,
>
> I actually figured it out-- using 'other' as my 'index'-- thanks to
> Raynald's great spss tools page. Now to figure out how to quickly loop
> this through all of my variables.
>
> Sarah





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email
me.
--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/SPSS-String-Trouble-tp5717243p
5717245.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
Reply | Threaded
Open this post in threaded view
|

Re: SPSS String Trouble

David Marso
Administrator
In reply to this post by Sarah T
Rereading your post:
string newvar (a200).
Please tell me you are not serious!
--
Sarah T wrote
Hi all,

I'm having trouble with some data manipulation. I have several string variables in my dataset. For many cases, the data takes on the form of "Other: abcdefg". I'd like to delete everything after 'Other', so any response starting with 'Other' only include that information (not the 'abcdefg').

I'm trying to do this with an RTRIM function, but I can't get it to work.

I first tried-

string newvar (a200).
COMPUTE newvar=rtrim(oldvar,"Other").
exe.


However, the error message that I'm getting and what I am reading seems to suggest that what I want to trim after must be just 1 character.

I can't use the ":" after 'Other' as there are some responses in my dataset that actually include ":" and I want to keep those. (for example, there may be responses like "blah blah: blah" that aren't preceded by 'Other' and thus I want to keep.

Help!
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: SPSS String Trouble

Art Kendall
In reply to this post by Sarah T
Without more information about you data it is difficult to be more specific.
do you have a set of string variables that could have the same response values?
Is you data entered manually so there might be variations for spelling, spacing, capitalization?
look up the commands below and see if something like this would help.
autorecode strvar1 to strvar5 into midvar1 to midvar5.
and its
group option.
then
recode midvar1 to midvar5 (18 thru 44 = 98)(else=copy) into newvar to newvar5.
add value labels newvar1 to newvar5  98 'collapsed others'.


Art Kendall
Social Research Consultants
On 1/6/2013 8:31 PM, Sarah T wrote:
Hi all,

I'm having trouble with some data manipulation. I have several string
variables in my dataset. For many cases, the data takes on the form of
"Other: abcdefg". I'd like to delete everything after 'Other', so any
response starting with 'Other' only include that information (not the
'abcdefg').

I'm trying to do this with an RTRIM function, but I can't get it to work.

I first tried-

/string newvar (a200).
COMPUTE newvar=rtrim(oldvar,"Other").
exe./

However, the error message that I'm getting and what I am reading seems to
suggest that what I want to trim after must be just 1 character.

I can't use the ":" after 'Other' as there are some responses in my dataset
that actually include ":" and I want to keep those. (for example, there may
be responses like "blah blah: blah" that aren't preceded by 'Other' and thus
I want to keep.

Help!



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SPSS-String-Trouble-tp5717243.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
Art Kendall
Social Research Consultants