trimming the decimal from a variable

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

trimming the decimal from a variable

Steve Dearwater
I need to create syntax that will drop only the decimal point from a
medical code variable leaving just the numbers and/or letters: (V43.6 to
V436; 995.84 to 99584; 34.08 to 3408). Some of the data will have leading
letters, some not. The decimal may fall in the 2nd character, 3rd
character, or 4th character. There is also variability whether there are
1, 2, or 3 characters to the right or left of the decimal. Some variables
will have only 3 characters with no decimal and need to remain unchanged.

Any help is greatly appreciated.

=====================
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: trimming the decimal from a variable

Edward Boadi
Hi Steve

Try this :

STRING NewCode (A10).
COMPUTE NewCode =Replace(OldCode,'.','').

Regards.

Edward.



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Steve Dearwater
Sent: Thursday, November 08, 2007 1:31 PM
To: [hidden email]
Subject: trimming the decimal from a variable


I need to create syntax that will drop only the decimal point from a
medical code variable leaving just the numbers and/or letters: (V43.6 to
V436; 995.84 to 99584; 34.08 to 3408). Some of the data will have
leading letters, some not. The decimal may fall in the 2nd character,
3rd character, or 4th character. There is also variability whether there
are 1, 2, or 3 characters to the right or left of the decimal. Some
variables will have only 3 characters with no decimal and need to remain
unchanged.

Any help is greatly appreciated.

=====================
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: trimming the decimal from a variable

Frederic Villamayor Forcada
In reply to this post by Steve Dearwater
Steve,

Try this syntax.


*Your original variable is 'codevar'.
STRING newvar(A8) /* Adjust to the necessary lenght*/.
COMPUTE newvar = SUBSTR(codevar,1,INDEX(codevar,'.')-1) .
EXECUTE .


Greetings


Frederic



Frederic Villamayor, BS
Researcher/Study Manager
Biostatistics Unit
Juan de Sada, 32
08028 Barcelona
Tel    +34 935093236
Fax   +34 934112764
[hidden email]
http://www.ferrergrupo.com 

Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede
contener información confidencial, siendo para uso exclusivo del
destinatario, quedando prohibida su divulgación, copia o distribución a
terceros sin la autorización expresa del remitente. Si Vd. ha recibido
este mensaje erróneamente, se ruega lo notifique al remitente y proceda a
su borrado. Gracias por su colaboración.

This message and its annexed files may contain confidential information
which is exclusively for the use of the addressee. It is strictly
forbidden to distribute copies to third parties without the explicit
permission of the sender. If you receive this message by mistake, please
notify it to the sender and make sure to delete it. Thank you for your
kind cooperation.




Steve Dearwater <[hidden email]>
Enviado por: "SPSSX(r) Discussion" <[hidden email]>
08/11/2007 19:30
Por favor, responda a
Steve Dearwater <[hidden email]>


Para
[hidden email]
cc

Asunto
[SPSSX-L] trimming the decimal from a variable






I need to create syntax that will drop only the decimal point from a
medical code variable leaving just the numbers and/or letters: (V43.6 to
V436; 995.84 to 99584; 34.08 to 3408). Some of the data will have leading
letters, some not. The decimal may fall in the 2nd character, 3rd
character, or 4th character. There is also variability whether there are
1, 2, or 3 characters to the right or left of the decimal. Some variables
will have only 3 characters with no decimal and need to remain unchanged.

Any help is greatly appreciated.

=====================
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: trimming the decimal from a variable

Frederic Villamayor Forcada
Steve and co-listers,

Please foeget my answer to your question! I missundestood it.
Of course, Edward Boadi's response is right.


Greetings, again

Frederic

Frederic Villamayor, BS
Researcher/Study Manager
Biostatistics Unit
Juan de Sada, 32
08028 Barcelona
Tel    +34 935093236
Fax   +34 934112764
[hidden email]
http://www.ferrergrupo.com 

Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede
contener información confidencial, siendo para uso exclusivo del
destinatario, quedando prohibida su divulgación, copia o distribución a
terceros sin la autorización expresa del remitente. Si Vd. ha recibido
este mensaje erróneamente, se ruega lo notifique al remitente y proceda a
su borrado. Gracias por su colaboración.

This message and its annexed files may contain confidential information
which is exclusively for the use of the addressee. It is strictly
forbidden to distribute copies to third parties without the explicit
permission of the sender. If you receive this message by mistake, please
notify it to the sender and make sure to delete it. Thank you for your
kind cooperation.




Frederic Villamayor Forcada <[hidden email]>
Enviado por: "SPSSX(r) Discussion" <[hidden email]>
09/11/2007 09:53
Por favor, responda a
Frederic Villamayor Forcada <[hidden email]>


Para
[hidden email]
cc

Asunto
Re: [SPSSX-L] trimming the decimal from a variable






Steve,

Try this syntax.


*Your original variable is 'codevar'.
STRING newvar(A8) /* Adjust to the necessary lenght*/.
COMPUTE newvar = SUBSTR(codevar,1,INDEX(codevar,'.')-1) .
EXECUTE .


Greetings


Frederic



Frederic Villamayor, BS
Researcher/Study Manager
Biostatistics Unit
Juan de Sada, 32
08028 Barcelona
Tel    +34 935093236
Fax   +34 934112764
[hidden email]
http://www.ferrergrupo.com 

Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede
contener información confidencial, siendo para uso exclusivo del
destinatario, quedando prohibida su divulgación, copia o distribución a
terceros sin la autorización expresa del remitente. Si Vd. ha recibido
este mensaje erróneamente, se ruega lo notifique al remitente y proceda a
su borrado. Gracias por su colaboración.

This message and its annexed files may contain confidential information
which is exclusively for the use of the addressee. It is strictly
forbidden to distribute copies to third parties without the explicit
permission of the sender. If you receive this message by mistake, please
notify it to the sender and make sure to delete it. Thank you for your
kind cooperation.




Steve Dearwater <[hidden email]>
Enviado por: "SPSSX(r) Discussion" <[hidden email]>
08/11/2007 19:30
Por favor, responda a
Steve Dearwater <[hidden email]>


Para
[hidden email]
cc

Asunto
[SPSSX-L] trimming the decimal from a variable






I need to create syntax that will drop only the decimal point from a
medical code variable leaving just the numbers and/or letters: (V43.6 to
V436; 995.84 to 99584; 34.08 to 3408). Some of the data will have leading
letters, some not. The decimal may fall in the 2nd character, 3rd
character, or 4th character. There is also variability whether there are
1, 2, or 3 characters to the right or left of the decimal. Some variables
will have only 3 characters with no decimal and need to remain unchanged.

Any help is greatly appreciated.

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

====================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: trimming the decimal from a variable

Albert-Jan Roskam
In reply to this post by Edward Boadi
Hi Steve,

I can't help wondering if you don't loose information
if you get rid of the decimal points. Perhaps it's ok
with the classification you are using, but will you
still be able to distinguish e.g. 34.08 from 340.8?
Decimal points (actually they're not really decimal
points here) can be really tricky in this context. For
instance, 1421.0 could indicate a very specific
medical procedure (5-digit level), whereas 1421
(4-digit level) would indicate an entire group.
Exporting it to Excel sometimes causes Excel to round
this. Tricky!

Cheers!!
Albert-Jan

--- Edward Boadi <[hidden email]> wrote:

> Hi Steve
>
> Try this :
>
> STRING NewCode (A10).
> COMPUTE NewCode =Replace(OldCode,'.','').
>
> Regards.
>
> Edward.
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion
> [mailto:[hidden email]] On Behalf Of
> Steve Dearwater
> Sent: Thursday, November 08, 2007 1:31 PM
> To: [hidden email]
> Subject: trimming the decimal from a variable
>
>
> I need to create syntax that will drop only the
> decimal point from a
> medical code variable leaving just the numbers
> and/or letters: (V43.6 to
> V436; 995.84 to 99584; 34.08 to 3408). Some of the
> data will have
> leading letters, some not. The decimal may fall in
> the 2nd character,
> 3rd character, or 4th character. There is also
> variability whether there
> are 1, 2, or 3 characters to the right or left of
> the decimal. Some
> variables will have only 3 characters with no
> decimal and need to remain
> unchanged.
>
> Any help is greatly appreciated.
>
> =====================
> 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
>


Cheers!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.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