Hi,
I have an SPSS file with a string variable containing values of the following kind: �56,070,577) �260,167) �3,754) �295,858) How can I remove the "�" and the brackets, so that I end up with the numbers alone? I have tried various procedures with Syntax which haven't worked. Could anyone post the correct Syntax? Your help is very much appreciated, best, peter |
This usually indicates that the file contain
characters not supported in your current locale encoding. The best solution
is to solve the encoding issue by using the proper encoding to read the
file. You say it's an "SPSS file", but I suspect it started as
something else, like a text data file. Assuming you are stuck with an SPSS
format data file of unknown origin and consequently unknown encoding, you
could try:
compute varname(substr, varname, 2). Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: SPSSPeter <[hidden email]> To: [hidden email], Date: 02/04/2014 01:56 PM Subject: deleting characters from a string in SPSS Sent by: "SPSSX(r) Discussion" <[hidden email]> Hi, I have an SPSS file with a string variable containing values of the following kind: �56,070,577) �260,167) �3,754) �295,858) How can I remove the "�" and the brackets, so that I end up with the numbers alone? I have tried various procedures with Syntax which haven't worked. Could anyone post the correct Syntax? Your help is very much appreciated, best, peter -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/deleting-characters-from-a-string-in-SPSS-tp5724325.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 |
Administrator
|
"compute varname(substr, varname, 2)."
Surely Rick, You mean some more like compute varname=CHAR.substr(varname, 2).
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?" |
My bad. Typing too fast and not thinking.
And yes, best to use char.substr, not the deprecated char function.
Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: David Marso <[hidden email]> To: [hidden email], Date: 02/04/2014 04:17 PM Subject: Re: deleting characters from a string in SPSS Sent by: "SPSSX(r) Discussion" <[hidden email]> "compute varname(substr, varname, 2)." Surely Rick, You mean some more like compute varname=CHAR.substr(varname, 2). Rick Oliver wrote > This usually indicates that the file contain characters not supported in > your current locale encoding. The best solution is to solve the encoding > issue by using the proper encoding to read the file. You say it's an "SPSS > file", but I suspect it started as something else, like a text data file. > Assuming you are stuck with an SPSS format data file of unknown origin and > consequently unknown encoding, you could try: > > compute varname(substr, varname, 2). > > Rick Oliver > Senior Information Developer > IBM Business Analytics (SPSS) > E-mail: > oliverr@.ibm > > > > From: SPSSPeter < > peter.muenchen@ > > > To: > SPSSX-L@.uga > , > Date: 02/04/2014 01:56 PM > Subject: deleting characters from a string in SPSS > Sent by: "SPSSX(r) Discussion" < > SPSSX-L@.uga > > > > > > Hi, > > I have an SPSS file with a string variable containing values of the > following kind: > > �56,070,577) > �260,167) > �3,754) > �295,858) > > How can I remove the "�" and the brackets, so that I end up with the > numbers > alone? I have tried various procedures with Syntax which haven't worked. > Could anyone post the correct Syntax? > Your help is very much appreciated, > best, > > peter > > > > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/deleting-characters-from-a-string-in-SPSS-tp5724325.html > > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- 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?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/deleting-characters-from-a-string-in-SPSS-tp5724325p5724327.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 |
Administrator
|
More important than the CHAR is the misplaced parentheses and scrambled code ;-)
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?" |
Administrator
|
In reply to this post by David Marso
That doesn't get rid of the right parenthesis. How about this (untested)?
COMPUTE varname=REPLACE(CHAR.substr(varname, 2),")","").
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Not sure why you need the CHAR.SUBSTR part.
This works... compute V1=replace(V1," ",""). compute V1=replace(V1,")",""). 56,070,577 260,167 3,754 295,858 -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver Sent: Tuesday, February 04, 2014 6:29 PM To: [hidden email] Subject: Re: [SPSSX-L] deleting characters from a string in SPSS That doesn't get rid of the right parenthesis. How about this (untested)? COMPUTE varname=REPLACE(CHAR.substr(varname, 2),")",""). David Marso wrote > "compute varname(substr, varname, 2)." > Surely Rick, > You mean some more like > compute varname=CHAR.substr(varname, 2). > Rick Oliver wrote >> This usually indicates that the file contain characters not supported >> in your current locale encoding. The best solution is to solve the >> encoding issue by using the proper encoding to read the file. You say >> it's an "SPSS file", but I suspect it started as something else, like >> a text data file. >> Assuming you are stuck with an SPSS format data file of unknown >> origin and consequently unknown encoding, you could try: >> >> compute varname(substr, varname, 2). >> >> Rick Oliver >> Senior Information Developer >> IBM Business Analytics (SPSS) >> E-mail: >> oliverr@.ibm >> >> >> >> From: SPSSPeter < >> peter.muenchen@ >> > >> To: >> SPSSX-L@.uga >> , >> Date: 02/04/2014 01:56 PM >> Subject: deleting characters from a string in SPSS >> Sent by: "SPSSX(r) Discussion" < >> SPSSX-L@.uga >> > >> >> >> >> Hi, >> >> I have an SPSS file with a string variable containing values of the >> following kind: >> >> 56,070,577) >> 260,167) >> 3,754) >> 295,858) >> >> How can I remove the " " and the brackets, so that I end up with the >> numbers alone? I have tried various procedures with Syntax which >> haven't worked. >> Could anyone post the correct Syntax? >> Your help is very much appreciated, >> best, >> >> peter >> >> >> >> -- >> View this message in context: >> http://spssx-discussion.1045642.n5.nabble.com/deleting-characters-fro >> m-a-string-in-SPSS-tp5724325.html >> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com. >> >> ===================== >> To manage your subscription to SPSSX-L, send a message to >> LISTSERV@.UGA >> (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 ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/deleting-characters-from-a-string-in-SPSS-tp5724325p5724330.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 This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations. ===================== 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 |
In reply to this post by David Marso
Yes. That is correct.
Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: David Marso <[hidden email]> To: [hidden email], Date: 02/04/2014 05:18 PM Subject: Re: deleting characters from a string in SPSS Sent by: "SPSSX(r) Discussion" <[hidden email]> More important than the CHAR is the misplaced parentheses and scrambled code ;-) Rick Oliver wrote > My bad. Typing too fast and not thinking. And yes, best to use > char.substr, not the deprecated char function. > > Rick Oliver > Senior Information Developer > IBM Business Analytics (SPSS) > E-mail: > oliverr@.ibm > > > > From: David Marso < > david.marso@ > > > To: > SPSSX-L@.uga > , > Date: 02/04/2014 04:17 PM > Subject: Re: deleting characters from a string in SPSS > Sent by: "SPSSX(r) Discussion" < > SPSSX-L@.uga > > > > > > "compute varname(substr, varname, 2)." > Surely Rick, > You mean some more like > compute varname=CHAR.substr(varname, 2). > > > Rick Oliver wrote >> This usually indicates that the file contain characters not supported in >> your current locale encoding. The best solution is to solve the encoding >> issue by using the proper encoding to read the file. You say it's an > "SPSS >> file", but I suspect it started as something else, like a text data > file. >> Assuming you are stuck with an SPSS format data file of unknown origin > and >> consequently unknown encoding, you could try: >> >> compute varname(substr, varname, 2). >> >> Rick Oliver >> Senior Information Developer >> IBM Business Analytics (SPSS) >> E-mail: > >> oliverr@.ibm > >> >> >> >> From: SPSSPeter < > >> peter.muenchen@ > >> > >> To: > >> SPSSX-L@.uga > >> , >> Date: 02/04/2014 01:56 PM >> Subject: deleting characters from a string in SPSS >> Sent by: "SPSSX(r) Discussion" < > >> SPSSX-L@.uga > >> > >> >> >> >> Hi, >> >> I have an SPSS file with a string variable containing values of the >> following kind: >> >> �56,070,577) >> �260,167) >> �3,754) >> �295,858) >> >> How can I remove the "�" and the brackets, so that I end up with the >> numbers >> alone? I have tried various procedures with Syntax which haven't worked. >> Could anyone post the correct Syntax? >> Your help is very much appreciated, >> best, >> >> peter >> >> >> >> -- >> View this message in context: >> > http://spssx-discussion.1045642.n5.nabble.com/deleting-characters-from-a-string-in-SPSS-tp5724325.html > >> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com. >> >> ===================== >> To manage your subscription to SPSSX-L, send a message to > >> LISTSERV@.UGA > >> (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 > > > > > > ----- > 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?" > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/deleting-characters-from-a-string-in-SPSS-tp5724325p5724327.html > > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- 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?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/deleting-characters-from-a-string-in-SPSS-tp5724325p5724329.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 |
Administrator
|
In reply to this post by MLIves
From the OP: 'How can I remove the "�" [which is in the initial position, given the examples provided] and the brackets, so that I end up with the numbers alone?'
Others had suggested the CHAR.SUBSTR approach to remove the "�". I was following up on that, but also removing the right bracket. In hindsight, one could also use RTRIM for that part. Cheers!
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Free forum by Nabble | Edit this page |