removing leading zeros

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

removing leading zeros

Zahid Abbas
Hello,
I have a variable that have data as:
0095-LIF                        
0099-SVW                        
0101-GEF                        
0106-FAM                        
0109-KAD                        
1110-JES                        
1111-SYB                        

I want to remove the leading zeros, dash and last three letters so that
the new variable looks like this
95
99
101
106
109
1110

Thank you for your assistance.

_________________________________________________________________
Enter today for your chance to win $1000 a day—today until May 12th. Learn more at SignInAndWIN.ca
http://g.msn.ca/ca55/215
====================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: removing leading zeros

Carsten Pauck
hello, this should work:


*strings are stored in the var first.

*removing the leading zeros.
string remZeros (a20).
comp remZeros = ltrim(first, '0').
exe.

*removing the last four chars (three letters and the dash).
string fin (a20).
comp fin = substr(remZeros,1, length(rtrim(remZeros))-4).
exe.



2008/3/20, Zahid Abbas <[hidden email]>:

> Hello,
> I have a variable that have data as:
> 0095-LIF
> 0099-SVW
> 0101-GEF
> 0106-FAM
> 0109-KAD
> 1110-JES
> 1111-SYB
>
> I want to remove the leading zeros, dash and last three letters so that
> the new variable looks like this
> 95
> 99
> 101
> 106
> 109
> 1110
>
> Thank you for your assistance.
>
> _________________________________________________________________
> Enter today for your chance to win $1000 a day—today until May 12th. Learn more at SignInAndWIN.ca
> http://g.msn.ca/ca55/215
> 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