Dear Community.
I am new in SAS and loosing my mind with this.
DATA TEST;
INPUT ID UB CONS WGT;
CARDS;
1 0 23 12
2 0 13 10
3 0 21 20
4 0 20 13
5 1 19 12
6 1 24 14
7 0 26 16
8 0 17 10
9 0 19 19
10 1 22 17
11 0 27 10
12 0 18 12
13 1 22 13
14 1 21 20
15 1 20 16
RUN;
Where:
- UB: is a dummy for whether one consumes a given beer or not
- CONS: is the reported number of bottle drank for a given period of time
- WGT is my sampling adjustment weight.
My data is from an online survey (no design), yet each respondent has a sampling adjustment weight to match the general population.
I want to estimate the mean consumption of beer and the corresponding 95% C.I for the two groups of UB (0,1) and test whether consumption is equal between the two groups.
Initially I ran this analysis in Stata and now I am tried to replicate it in SAS. I got the same weighted mean but different 95% C.I.
STATA Codes: Since STATA does not allow for weighted t-test, I ran a mean estimation (accounting for weight) and used test after mean estimation to compare the two means.
. mean CONS [pweight=WGT], over(UB)
. test [CONS]0=[CONS]1
. test | [CONS]0=[CONS]1 |
( 1) | [CONS]0 - [CONS]1 | = 0 |
| F( 1, 14) = | 0.26 |
Prob > F = | 0.6202 |
|
In SAS, I am getting the same means but different 95% Confidence intervals.
Analysis Variable : CONS |
UB | N Obs | Mean | Lower 95% CL for Mean | Upper 95% CL for Mean |
0 | 9 | 20.6475410 | 17.5247509 | 23.7703311 |
1 | 6 | 21.3478261 | 19.6156577 | 23.0799944 |
Can some body help with this?