Statalist The Stata Listserver


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

st: String problem


From   "Kelvin Foo" <kelvinski@gmail.com>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: String problem
Date   Sun, 3 Sep 2006 21:25:53 +0100

Dear Statalisters,

I have a macro `covars' which is a list of variables, var1 var2
var3... var19 var20
I would like to exclude the last variable, var20, from `covars' so
this is what I did:

local revcovs=reverse("`covars'")
gettoken dropped revcovs: revcovs
local covars=reverse("`revcovs'")

I'm sure there must be some way more elegant, just that I can't think
of it. Any suggestions?

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?

Thanks in advance for any suggestions!

Kelvin
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index