Bookmark and Share

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


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

Re: st: coding for weighting factor variable -weight-


From   Steve Samuels <sjsamuels@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: coding for weighting factor variable -weight-
Date   Tue, 31 Jan 2012 17:37:58 -0500

I'm not sure that I understand your question completely,  but I think that you want a weighted average of variables from two observations to be put into a single observation.  If so, -collapse- provides a way.

*************CODE BEGINS*************
sysuse auto, clear
keep in 1/2 
drop make
gen part = _n // 
label define part 1 "West" 2 "East"
label values part part
list mpg weight length trunk part

gen myweight = 1.23 if part==1
replace myweight= 0.55 if part==2
collapse mpg weight length trunk [pw =myweight]
gen country ="Germany"
list
**************CODE ENDS**************


By the way, "STATA" is not correct spelling of the program we all use, but "Stata" is. See the end of the Statalist FAQ for the reason. 

Steve
sjsamuels@gmail.com


On Jan 31, 2012, at 3:36 PM, David Cefskimal wrote:

Dear statlisters,

I create a variable "Germany" but when the whole country is taken as
the unit of analysis (rather than eastern and western states), a
design weight is necessary: weighting factor for Western Germany:
1,23; weighting factor for Eastern Germany: 0,55.

As the help weight command did not solve my problem, I would be v.
thankful if someone could tell me how to code that in STATA. Many
thanks, David
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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