I just realized that -c_local- isn't documented, so you can't
find out what it does (though you can probably guess by
reading the code). -c_local- is explained in this post:
http://www.stata.com/statalist/archive/2005-11/msg00405.html
(I think Nick should stay away from the stash of mushrooms he
collected in the 70s)
Hope this helps,
Maarten
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Maarten Buis
Sent: vrijdag 13 juli 2007 14:54
To: [email protected]
Subject: RE: st: RE: Generating grouped variable list of xi'd variables via column names
--- K Jensen wrote:
> I was wondering how easy it would be to convert the results in
> model_I
> di "`model_I'"
> _Idrug_2 _Idrug_3 _Irandcat_2 _Irandcat_3
> to the form _Idrug* _Irandcat*
A slightly messy solution is shown below. As you are probably
using this repeatedly in your do-file it might be useful to
create a program at the beginning of your do-file that does
this (call it -ab_i-), so in the remainder of your do-file you
can refer to -ab_I- whenever you want to do this. This way
your do-file will look cleaner and easier to understand (and
debug).
*------------- begin example -------------
capture program drop ab_I
program define ab_I
*!version 1.0.0 MLB 13 July 2007
/*get list of all _I vars*/
qui indeplist, local
unab all_I : _I*
local model_I : list all_I & X
/*abbreviate _I vars*/
local min_I : subinstr local model_I "_I" "", all
foreach stub of local min_I {
gettoken temp : stub, parse("_")
local ab "`ab' _I`temp'*"
}
local ab : list uniq ab
c_local ab "`ab'"
end
sysuse cancer, clear
stset studytime, fail(died)
gen randcat= ceil(3*uniform())
xi:stcox i.drug age i.randcat
ab_I
di "`ab'"
*--------------- end example -------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
Hope this helps,
Maarten
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
*
* 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/
*
* 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/