/* This sas program will produce the estimates in Example 4.1 of Sampling: Design and Analysis by Sharon L. Lohr, using Version 7 of SAS */ /* Author: S. Lohr, 3/99. Copyright (c) Sharon L. Lohr, 1999*/ options ls=78 ps=35; /* Create dataset containing strata totals */ data strattot; input region $ _total_; cards; NE 220 NC 1054 S 1382 W 422 ; proc print data=strattot; data agstrat; infile '~atsll/public/stp535/bookdata/agstrat.dat' delimiter=',' firstobs =2; input county $ state $ acres92 acres87 acres82 farms92 farms87 farms82 largef92 largef87 largef82 smallf92 smallf87 smallf82 region $ rn weight; if acres92 < 200000 then lt200k = 1; else lt200k = 0; /* counties with fewer than 200000 acres in farms */ if acres92 = -99 then acres92 = . ; /* check for missing values */ if acres92 = -99 then lt200k = . ; proc sort data=agstrat; by region; proc means data=agstrat mean sum std; by region; var acres92 weight; proc means data=agstrat mean sum std; var acres92 weight; /* Note that without the weight variable this just does the SRS mean SAS simply assigns every observation a weight of 1 */ proc surveymeans data=agstrat total = strattot nobs mean sum; strata region /list; var acres92 lt200k; /* Here's the correct way to do the analysis */ proc surveymeans data=agstrat total = strattot nobs mean sum; stratum region /list; var acres92 lt200k; weight weight; ods output Statistics=myout; proc print data=myout;