I use the accumulated dataset from the European Social Survey (ESS) for the waves 1 to 5 and appended the data from wave 6. I'm trying to calculate means for the variable trstprl (Trust in country's parliament). My goal is to get weighted means for every country in my dataset for every wave. The ESS dataset contains two weight-variables, dweight and pweight.
dweight is labelled as design weight (Quoting from the instruction on the weighting variables: "The main purpose of the design weights is to correct for the fact that in some countries respondents have different probabilities to be part of the sample due to the sampling design used"), the other one is pweight ("The main purpose of the design weights is to correct for the fact that in some countries respondents have different probabilities to be part of the sample due to the sampling design used")
I looked at another post in this forum that was already of great help. According to that example, I constructed a loop. So to calculate weighted means I constructed a loop where the means are calculated by using dweight that looks as follows:
gen trst = .
forvalues i = 1/6 {
levelsof cntry, local(levels)
foreach j of local levels {
sum trstprl [pweight = dweight] if cntry == "`j'" && essround == `i', detail
replace trst = r(mean) if cntry == "`j'" && essround == `i'
}
}
When executing this loop I always get the following error message:
pweight not allowed
r(101)
If I use weight instead of pweight in the loop it executes without error message . However, Stata then assumes analytic weights which are, if I am not mistaken, not correct for this purpose.
Any suggestions?
I am using Stata 12.1 on a MacBook operating on Mac OS X 10.9.2 (Mavericks).
dweight is labelled as design weight (Quoting from the instruction on the weighting variables: "The main purpose of the design weights is to correct for the fact that in some countries respondents have different probabilities to be part of the sample due to the sampling design used"), the other one is pweight ("The main purpose of the design weights is to correct for the fact that in some countries respondents have different probabilities to be part of the sample due to the sampling design used")
I looked at another post in this forum that was already of great help. According to that example, I constructed a loop. So to calculate weighted means I constructed a loop where the means are calculated by using dweight that looks as follows:
gen trst = .
forvalues i = 1/6 {
levelsof cntry, local(levels)
foreach j of local levels {
sum trstprl [pweight = dweight] if cntry == "`j'" && essround == `i', detail
replace trst = r(mean) if cntry == "`j'" && essround == `i'
}
}
When executing this loop I always get the following error message:
pweight not allowed
r(101)
If I use weight instead of pweight in the loop it executes without error message . However, Stata then assumes analytic weights which are, if I am not mistaken, not correct for this purpose.
Any suggestions?
I am using Stata 12.1 on a MacBook operating on Mac OS X 10.9.2 (Mavericks).
Comment