Usage Note 24497: Can I get adjusted or least-squares means (LSMEANS) in PROC SURVEYREG?
Beginning with SAS/STAT 9.22 in SAS 9.2 TS2M3, you can use the LSMEANS statement in PROC SURVEYREG to compute and compare least squares means (LS-means) of fixed effects.
Prior to SAS 9.2 TS2M3, you can compute least-squares means by using the ESTIMATE statement. Use the desired LSMEANS statement in PROC GLM, and specify the E option to generate the appropriate coefficients for use in the ESTIMATE statement in PROC SURVEYREG.
The following statements create data sets to be analyzed by PROC SURVEYREG. LSMEANS for the two states, Iowa and Nebraska, are desired.
data Farms;
input State $ Region FarmArea CornYield Weight;
datalines;
Iowa 1 100 54 33.333
Iowa 1 83 25 33.333
Iowa 1 25 10 33.333
Iowa 2 120 83 10.000
Iowa 2 50 35 10.000
Iowa 2 110 65 10.000
Iowa 2 60 35 10.000
Iowa 2 45 20 10.000
Iowa 3 23 5 5.000
Iowa 3 10 8 5.000
Iowa 3 350 125 5.000
Nebraska 1 130 20 5.000
Nebraska 1 245 25 5.000
Nebraska 1 150 33 5.000
Nebraska 1 263 50 5.000
Nebraska 1 320 47 5.000
Nebraska 1 204 25 5.000
Nebraska 2 80 11 10.000
Nebraska 2 48 8 10.000
Nebraska 3 180 13 10.000
Nebraska 3 148 28 10.000
;
data TotalInStrata;
input State $ Region _TOTAL_;
datalines;
Iowa 1 100
Iowa 2 50
Iowa 3 15
Nebraska 1 30
Nebraska 2 20
Nebraska 3 20
;
Prior to the analysis by PROC SURVEYREG, fit the model in PROC GLM and include the desired LSMEANS statement with the E option to display the LSMEANS coefficients. The ODS SELECT statement selects only the table of LSMEANS coefficients for display
ods select LsMeanCoef;
proc glm data=Farms;
class State Region;
model CornYield = state region FarmArea State*Region;
weight Weight;
lsmeans state / e;
run;
quit;
1 |
1 |
1 |
0 |
0 |
1 |
0.33333333 |
0.33333333 |
0.33333333 |
0.33333333 |
0.33333333 |
0.33333333 |
130.666667 |
130.666667 |
0.33333333 |
0 |
0.33333333 |
0 |
0.33333333 |
0 |
0 |
0.33333333 |
0 |
0.33333333 |
0 |
0.33333333 |
Now fit the model in PROC SURVEYREG and include an ESTIMATE statement for each LSMEAN that specifies the coefficients as provided by PROC GLM.
proc surveyreg data=Farms total=TotalInStrata;
strata State Region / list;
class State Region;
model CornYield = state region FarmArea State*Region /solution;
weight Weight;
estimate 'Lsmean for State=Iowa'
intercept 1 state 1 0 region .333333 .333333 .333333
farmarea 130.666667 state*region .333333 .333333 .333333 0 0 0;
estimate 'Lsmean for State=Nebraska'
intercept 1 state 0 1 region .333333 .333333 .333333
farmarea 130.666667 state*region 0 0 0 .333333 .333333 .333333;
run;
Following are results from the ESTIMATE statements. Currently, confidence intervals for the estimates are not available.
54.9156660 |
4.69738296 |
11.69 |
<.0001 |
14.7054762 |
5.90293785 |
2.49 |
0.0249 |
Operating System and Release Information
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Type: | Usage Note |
Priority: | low |
Topic: | Analytics ==> Regression Analytics ==> Survey Sampling and Analysis SAS Reference ==> Procedures ==> SURVEYREG
|
Date Modified: | 2011-03-08 11:29:09 |
Date Created: | 2006-03-09 16:43:15 |