Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: data management

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: data management
Date   Wed, 18 Feb 2004 11:55:41 -0000

Richard Williams replied to Anuja Saurkar

> >3) I am using weights:
> >so generally I write
> >
> >tabstat variable [aweight=weight] by variable....
> >
> >Is there any way I can use weights without including
> >it in the tabstat command? I want to run a bunch of
> >summary table, would like to use weights for all of
> >them.
> I suspect not, but I am curious too.  A difference that 
> strikes me between 
> SPSS and Stata is that, in SPSS, I can specify weights or 
> filters (i.e. 
> temporary sample selections) and they continue to hold until 
> I tell SPSS 
> otherwise; in Stata I have to keep on specifying the weights 
> or filters 
> with every command.

I think Richard is right. There is no way of setting analytic 
weights. (In a separate posting Rafa De Hoyos mentions setting 
survey weights, which does not seem to apply to this problem.) 

The design issue is straightforward, a trade-off between 
setting things until they're changed, and thus saving on 
typing, and of overlooking what you've set. Stata lets
you set various things, but not analytic weights. 

Historically, one good reason for that was that typing 
the same stuff is usually easy with facilities like PageUp. 

Another is that long weight specification can be saved 
in local macros 

local myw "[aw=verylongvariablename]" 

tabstat variable `myw' 

More recently, -foreach- makes it a lot easier 
to cycle round almost similar stuff 

foreach v of var <varlist> { 
	tabstat `v' [aw=weight] , by(<whatever>) 

and I guess wildly that may be the most practical 
answer to Anuja's problem, which appears to be 
wanting to cut down on typing. 

[email protected] 

*   For searches and help try:

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