Statalist The Stata Listserver


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

RE: st: String problem


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: String problem
Date   Mon, 4 Sep 2006 18:44:15 +0100

Now you tell us!

Another way of doing that 

local nv : word count `covars' 
local last : word `nv' of `covars' 
local covars : list covars - last 

Nick 
[email protected] 

Kelvin Foo
 
> Yes, I want my program to remove the last variable in the list, which
> can take any name, not necessarily "var20". My problem was solved by
> using extended functions like the ones you two suggested.
> 
> Thanks Dimitriy and Nick for the help!
 
> On 9/4/06, Nick Cox <[email protected]> wrote:
> > An alternative is
> >
> > local covars : subinstr local covars "var20" ""
> >
> > but this doesn't work word-wise and might catch
> > text you don't want it to catch before the occurrence
> > of "var20". (I have in mind that your real problem
> > may be with variable names other than those you
> > give in the example.)
> >
> > local purge var20
> > local covars : list revcovs - purge
> >
> > is probably better.

Dimitriy V. Masterov

> > > On 9/3/06, Kelvin Foo <[email protected]> wrote:
> > > > Elegance aside, my variable list, if too long, would 
> get truncated
> > > > because I assigned the macro revcovs with the "=" sign 
> in the first
> > > > line of my above code. Is there anyway to avoid the "=' 
> sign in that
> > > > line?
> > >
> > > There is a way to get around the character limit for parsing:
> > >
> > > local purge "var20"
> > > local covars: list revcovs - purge
> > >
> > > It's not very elegant. It seems like you should be able to do
> > > something like
> > >
> > > local covars: list revcovs - "var20",
> > >
> > > but I don't know how to get it to work.

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