Statalist The Stata Listserver


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

Re: st: ends (egen)


From   [email protected]
To   [email protected]
Subject   Re: st: ends (egen)
Date   Wed, 20 Sep 2006 07:31:13 -0500

Can you provide an example?

In the simple example below, I believe -egen, ends()- is correctly 
separating the head from the tail in the long string (str229).

Scott

clear
set obs 1
local string = c(alpha)
forv i = 1/10 {
	foreach a of local string {
		local st = "`st'`a'"
	}
	local string = c(Wdays)
	if `i' <10 {
		local st = "`st'`a',"
	}	
	if `i' == 9 {
		local string = c(ALPHA)
	}
}
gen foo = "`st'"
egen foo1 = ends(foo), punct(,) head trim
egen foo2 = ends(foo), punct(,) last trim
egen foo3 = ends(foo), punct(,) tail trim
desc
l foo1 foo2


----- Original Message -----
From: Marcello Pagano <[email protected]>
Date: Wednesday, September 20, 2006 6:29 am
Subject: st: ends (egen)
To: [email protected]

> 
> [email protected] wrote:
> > I am working with very long string variables which I need to 
> break up 
> > in different ways. To do so I am using the ends (egen) command. 
> After 
> > some puzzling results (i.e. the command was working on some 
> variables 
> > but not on others), I think I discovered that  the ends (egen) 
> command 
> >  only  searches for the specified text over the first 110/112 
> > characters. Is this correct? If so, is there anyway to force the 
> > command to span all characters? If not, I think a warning should 
> be 
> > introduced in the STATA manuals.
> >

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