Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: substr() addition


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: substr() addition
Date   Mon, 30 Sep 2002 07:55:16 -0400

Why not just :

gen str20 newdose = substr(dose,1,length(dose)-2)


Michael Blasnik

----- Original Message -----
From: <[email protected]>
Sent: Monday, September 30, 2002 7:23 AM
Subject: st: substr() addition


> Is there a better way of trucating a string variable? I just wanted to
> delete the
> last two characters of a variable and had to do use the reverse() function
>
> gen str20 newdose = reverse(substr(reverse(dose),3,.)
>
> I was wondering whether it would have been better to have the option in
> substr() to go backwards along the
> string perhaps instead of having a .  having a -. :) hence instead of
going
> to the end of the string with the .
> you could actually go to the start of the string....?
>
> cheers
> Ade
>


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index