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

Re: st: removing blanks in string variable


From   Philip Ryan <[email protected]>
To   [email protected]
Subject   Re: st: removing blanks in string variable
Date   Thu, 16 Jan 2003 23:44:04 +1030

The function -subinstr()- appears to work:

. clear
. input str12 x

x
1. "123 456 789"
2. end

. gen str12 y = subinstr(x," ","",.) /* note 2nd argument is space, 3rd is null string,
4th is a period, signifying all spaces are to be eliminated */

. compress
. list

x y
1. 123 456 789 123456789


Phil



At 01:46 PM 16/01/2003 +0100, you wrote:

I have a string variable, which looks like "12 34 56 78". How can I remove
the blanks to obtain "12345678" ? I guess it can be done with -gen
x=subinstr(s1,s2,s3,n), but I do not get the syntax correct. I checked the
archives and the FAQs without success.

Thanks in advance, greetings,
-- Daniel


*
*   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/
Philip Ryan
Associate Professor
Department of Public Health
Medical School
University of Adelaide
Adelaide 5005
South Australia

tel: +61 8  83033570
fax: +61 8 82234075

[email protected]
http://www.public-health.adelaide.edu.au/

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