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

st: How to create a weighted variable?


From   "Deborah Garvey" <[email protected]>
To   <[email protected]>
Subject   st: How to create a weighted variable?
Date   Thu, 16 Jan 2003 17:38:53 -0800

Dear listers,

I have an 8-year panel of school district-level data.  I need to calculate the mean of the year-to-year changes in enrollment-weighted spending.  This is not as easy as it sounds, as the data are not weighted -- they're at the district level.  I can't use the summ command to calculate a weighted average, because I need to calculate the mean of the weighted differences, not the weighted mean of the unweighted differences.

I can't figure out a way to "create" an enrollment-weighted spending variable.  I tried to use the collapse command, but as you can see from the output below, something is wrong.

Any ideas?  I'm frustrated by something so seemingly easy....

Thanks for your help,

Deb Garvey

. use "D:\school finance centralization\data\waoranal2"

. su instrpp [aw=adm] if year == 77 & statefip == 41

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
     instrpp |     152  385645.500    948.8115   110.5098   610.7853   1802.382

. sort statefip sd_id year

. collapse instrpp [aw=adm], by(statefip sd_id year)

. su instrpp if statefip == 41 & year == 77

    Variable |     Obs        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------
     instrpp |     152    976.8409   176.8611   610.7853   1802.382



******************************
Deborah Garvey, Ph.D.
Department of Economics
Kenna Hall
Santa Clara University
Santa Clara, CA  95053
408/554-5580
408/554-2331 (FAX)
[email protected]    
http://lsb.scu.edu/~dgarvey
**********************************

*
*   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