![]() | ![]() | ![]() |
PROC SURVEYMEANS does a univariate analysis, and so it does not provide any tests for comparing means of different variables or domains. You can use PROC SURVEYREG to compare means instead.
The following DATA step creates a data set named SAMPLE, representing a stratified and clustered sample design. Measurements are obtained on three variables, X1, X2 and X3, and there is a domain variable D with two levels.
data sample;
w=1;
seed=273497;
do str=1 to 2;
do clus=1 to 3;
do i=1 to 5;
d=ceil(2*ranuni(seed));
X1=rannor(seed);
X2=rannor(seed);
X3=rannor(seed);
output;
end;
end;
end;
drop seed i;
run;
proc print data=sample(obs=10);
run;
Here is the partial printout of the data set
|
PROC SURVEYMEANS can compute the overall and domain means and their standard errors as follows.
proc surveymeans data=sample;
domain d;
cluster clus;
strata str;
weight w;
var X1 X2 X3;
run;
In order to use PROC SURVEYREG for variable means comparisons, first reshape the data so that it is arranged for an ANOVA. That is, so that all the measurements are in a single variable and there is a class indicator variable. This DATA step creates the analysis variable MEASUREMENT containing the X1, X2 and X3 values and the class variable GROUP.
data sample2;
set sample;
array num (*) x1 x2 x3;
length group $ 8;
do i=1 to dim(num);
measurement=num[i];
call vname(num[i], group);
output;
end;
drop x1 x2 x3 i;
run;
proc print data=sample2(obs=10);
run;
Here is the partial printout of the reshaped data.
|
To set up an equivalent analysis in PROC SURVEYREG, specify the same design and weight statements that you had in PROC SURVEYMEANS. The model response variable is MEASUREMENT, the set of all analysis variable values from the reshaped data, and the independent class variable is GROUP, the ID variable also created in the reshaped data. It is convenient to specify a no-intercept model with the NOINT option, so that the parameter estimates are equal to the analysis variable means. The following CONTRAST statement in PROC SURVEYREG compares the means of X1, X2 and X3.
proc surveyreg data=sample2;
cluster clus;
strata str;
weight w;
class group;
model measurement=group/noint solution vadjust=none;
contrast 'Ho: X1=X2=X3' group 1 -1 0,
group 1 0 -1;
run;
|
Regression Analysis for Dependent Variable
measurement
| |||||||||||||||||||||||||||||||||||||||||
Note that the VADJUST= option is specified. VADJUST=DF by default in PROC SURVEYREG, which uses the degrees of freedom adjustment factor (n-1)/(n-p) in the G matrix. This results in different variance estimates in PROC SURVEYREG than those obtained in PROC SURVEYMEANS. By using VADJUST=NONE, the same variance estimates can be obtained in PROC SURVEYREG. The VADJUST= option was added in SAS 9.1. Prior to SAS 9.1, you would have to use the %SMSUB macro to compute contrasts for variables or domain levels.
You can compare the domain means using the original data set. This code compares the mean of X1 between the two domains.
ods select parameterestimates contrasts;
proc surveyreg data=sample;
cluster clus;
strata str;
weight w;
class d;
model X1=d/noint solution vadjust=none;
contrast 'X1: D1 vs D2' d 1 -1;
run;
|
Regression Analysis for Dependent Variable X1
| ||||||||||||||||||||||||||||||||||||
| Product Family | Product | System | SAS Release | |
| Reported | Fixed* | |||
| SAS System | SAS/STAT | 64-bit Enabled Solaris | ||
| 64-bit Enabled HP-UX | ||||
| 64-bit Enabled AIX | ||||
| Windows Millennium Edition (Me) | ||||
| Windows Vista | ||||
| Microsoft Windows XP Professional | ||||
| Microsoft Windows Server 2003 Standard Edition | ||||
| Microsoft Windows Server 2003 Enterprise Edition | ||||
| Microsoft Windows Server 2003 Datacenter Edition | ||||
| Microsoft Windows NT Workstation | ||||
| Microsoft Windows 2000 Professional | ||||
| Microsoft Windows 2000 Server | ||||
| Microsoft Windows 2000 Datacenter Server | ||||
| Microsoft Windows 2000 Advanced Server | ||||
| OS/2 | ||||
| Microsoft Windows 95/98 | ||||
| Microsoft® Windows® for x64 | ||||
| Microsoft Windows XP 64-bit Edition | ||||
| Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
| Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
| Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
| OpenVMS VAX | ||||
| z/OS | ||||
| ABI+ for Intel Architecture | ||||
| AIX | ||||
| HP-UX | ||||
| HP-UX IPF | ||||
| IRIX | ||||
| Linux | ||||
| Linux for x64 | ||||
| Linux on Itanium | ||||
| OpenVMS Alpha | ||||
| OpenVMS on HP Integrity | ||||
| Solaris | ||||
| Solaris for x64 | ||||
| Tru64 UNIX | ||||
| Type: | Usage Note |
| Priority: | |
| Topic: | Analytics ==> Analysis of Variance Analytics ==> Regression Analytics ==> Survey Sampling and Analysis SAS Reference ==> Procedures ==> SURVEYMEANS SAS Reference ==> Procedures ==> SURVEYREG |
| Date Modified: | 2010-03-30 14:32:45 |
| Date Created: | 2009-01-27 12:30:44 |



