P Please Consider the Environment before Printing this e-mail
|
Hi,
I have a numeric value that is currently a string variable in the following format '03 1234567' and I want to convert it to a numeric variable, however due the space in the middle it becomes system missing.
Is there some way that I can remove the blanks from within the string variable so I can convert it to numeric?
Generally the space is after the 2nd or 5th number.
Thanks
Andrew Unintended Recipient: This message (and/or any files transmitted with it) contains confidential and/or privileged information for use by the intended recipient. If you have received this message in error, we apologise and request that you immediately destroy all trace of this message and/or attached files and do not use, copy, disseminate or otherwise action. It would also be appreciated if you could notify the Help Desk on 0800 502 442. Disclaimer: Any views expressed in this message (or attached files) are those of the individual sender, except where the message clearly states otherwise and the sender is authorised to state them to be the views of the organisation. P Please Consider the Environment before Printing this e-mail -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. |
|
Hi Andrew You nee the REPLACE function, in which you
tell it to replace a space character with nothing. I’m assuming you don’t
want to be left with any spaces anywhere - String VAR_NO_SPACES (a10). (Assuming the
variable will have no more than 10 characters, and assuming you don’t
want to destroy your original variable) Compute VAR_NO_SPACES = replace(VAR_WITH_SPACES,’
‘,’’). (This can get a bit more involved whn the
task is to replace multiple instances of a string with a single instance, in
which case you need to place the command in a loop which will execute until
there are no more instances of the multiple-character string) Regards, Adrian
Barnett Information Analyst Educational Measurement and Analysis Data Management DECS ph 82261080 From: SPSSX(r) Discussion
[mailto:[hidden email]] On Behalf
Of Andrew Rudd Hi, I have a numeric value that is
currently a string variable in the following format '03 1234567' and I want to
convert it to a numeric variable, however due the space in the middle it
becomes system missing. Is there some way that I can
remove the blanks from within the string variable so I can convert it to
numeric? Generally the space is after the
2nd or 5th number. Thanks Andrew Unintended Recipient: This message (and/or
any files transmitted with it) contains confidential and/or privileged information
for use by the intended recipient. If you have received this message in error,
we apologise and request that you immediately destroy all trace of this message
and/or attached files and do not use, copy, disseminate or otherwise action. It
would also be appreciated if you could notify the Help Desk on 0800 502 442. Disclaimer: Any views expressed in this message (or attached files)
are those of the individual sender, except where the message clearly states
otherwise and the sender is authorised to state them to be the views of the
organisation. P Please Consider the Environment
before Printing this e-mail -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. |
| Free forum by Nabble | Edit this page |
