Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: cut string variables


From   "Sebastian F. B�chte" <[email protected]>
To   [email protected]
Subject   Re: st: cut string variables
Date   Tue, 23 May 2006 09:35:12 +0200

Richard,

your solution will leave Susanne with her original problem, having a
variable with more than 80 characters. So building on your approach I
would suggest:

//generate word2, containing all characters from variable word1 located at
//position 51 or greater
gen str word2=substr(word1,51,.)

//replace word1 with an extract of its first 50 characters max
replace word1=substr(word1,1,50)

//make sure word1 is no longer a str102 type
compress word1

Regards,
Sebastian

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