Statalist The Stata Listserver


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

Re: st: 'Wildcard with exceptions' syntax


From   "Kelvin Foo" <[email protected]>
To   [email protected]
Subject   Re: st: 'Wildcard with exceptions' syntax
Date   Fri, 29 Dec 2006 19:53:16 +0000

Hi, I believe macro list is the best way then. I was wondering if
there existed some wildcard syntax similar to what I suggested. I
guess not. Thanks Kit and Sergio for your prompt replies.

Kelvin.


On 12/29/06, Sergio Correia <[email protected]> wrote:
You can use the -unab- command (or tsunab if you are using time-series
operators), mixed with a macro function:

An example could be:

unab allvars : int_*
unab excludedvars : int_abc int_xyz
local selected : list allvars - excluded

And then you use the local macro -selected- like this:

 reg y x1 x2 `selected'

You will see that the results do the same as (int_* - int_abc - int_xyz)

Cheers,
Sergio

PS: Its not in one line, but after you create the macro you can use it
everywhere, from summ to xtprobit

On 12/29/06, Kit Baum <[email protected]> wrote:
Kelvin wants to use a wildcard list and remove a couple of elements
from the list. The list macro functions are useful in that regard:

webuse auto,clear
tab rep78,g(RR)
unab rnames: RR*
local dontwant RR2 RR4
local rnames1 : list rnames - dontwant
di "`rnames1'"
su `rnames1'


Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html

On 12/29/06, Kelvin Foo <[email protected]> wrote:
> Dear Statalisters,
>
> How can I do the following?
>
> reg y x1 x2 (int_* - int_abc - int_xyz)
>
> Obviously the above doesn't work.
>
> "(int_* - int_abc - int_xyz)" is supposed to mean the varlist of all
> variable names starting with int_ except int_abc and int_xyz, and in
> place of int_abc and int_xyz could be any other variable names that I
> specify.
>
> I would need this syntax to be part of the varlist that goes with any
> estimation commands such as -reg-, -probit-, etc.
>
> Thanks.
>
> 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/
>
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index