Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: e(wexp) versus e(wexp): different routines return different things

From   "Rodini, Mark" <[email protected]>
To   <[email protected]>
Subject   st: e(wexp) versus e(wexp): different routines return different things
Date   Fri, 26 Aug 2011 18:49:59 -0700


I have a program which executes after I run an estimation procedure, and it does a collapse where weighting is an option.
Within the program is the following line:

if "`e(wexp)'" != "" {
			collapse (mean) `y_sample' `xb_sample' [fw `e(wexp)']

I'm running an estimation using "reg" and one using "newey2".  Suppose the name of the weighting variable, should I opt to use it, is "mycount" so for example, I run:

reg y high low cows [aw=mycount]

and then execute the program.

Both estimation routines create as output an estimation "variable" called e(wexp).  Note that this is what is passed to the program as indicated above.

Here is the kicker: reg returns e(wexp) as "= mycount", but newey2 returns e(wexp) as "mycount" (without the equals sign!)

The reg version properly executes the program above, but newey2 gives an error about an inability to weight, since the syntax requires an equals sign.

I have tried within the program to create a tempname or tempvar, assign e(wexp) to it and then tried running

scalar `wts'=regexr(`e(wexp)',"=","")

I then replace the `e(wexp)' in the program with `wts' and add an equals sign explicitly in the program.  The idea I was hoping for is that it would replace the "=" with nothing in the macro variable, if one were there.

No matter how I try it, it fails, usually with a type mismatch error.  I tried adding double quotes, etc.  I am assuming that because I'm trying to pass it as a scalar, that is what bombs it.  Any thoughts?  I'm guessing it's something pretty basic --I'm kind of new to writing complicated programs which pass lots of stuff.

Thanks much.


Mark Rodini
1111 Broadway, Suite 1500
Oakland, CA  94607
510-285-1258 (direct)
510-285-1240 (main)
510-285-1245 (fax)
[email protected]
This e-mail and attachments may be confidential and protected by legal privilege.  If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the e-mail or any attachment is prohibited.  If you have received this e-mail in error, please notify us immediately by replying to the sender, and then delete this copy and the reply from your system.  Thank you for your cooperation.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index