In SURVEYSELECT you can requests optimal allocation, which allocates the total sample size
among the strata in proportion to stratum sizes and stratum variances.
You can use the option ALLOC=OPTIMAL and give the stratum variances with VAR=(values). The question: Is possible to use it with many variables? (many variances for each stratum) Thanks and regards!
The short answer is no. You could however provide proc surveyselect with a measure of the overall variance of your variables. The determinant of the covariance matrix of your variables can be considered as such an estimate of the overall variance. It can be calculated for each strata by proc discrim. Use ODS to transfer the information from discrim to surveyselect. This example shows you how:
proc sort data=sashelp.class out=myClass; by sex; run;
/* Get the determinant of the covariance matrix within each stratum */
ods select LogDet;
proc discrim data=myClass pool=no noclassify;
class sex;
var weight height age;
ods output LogDet=sexLogDet;
run;
/*
Output dataset sexLogDet includes variables
FromSex : name of sex group (M or F)
LogDet : logarithm of the determinant of the covariance matrix of each stratum
*/
/* Create table containing strata variances */
proc sql;
create table sexVar as
select
FromSex as sex length=1, /* Length must match variable in myClass dataset */
exp(LogDet) as _VAR_
from sexLogDet
order by sex;
quit;
proc surveyselect data=myClass out=mySample sampsize=5;
strata sex / alloc=Neyman var=sexVar;
run;
The short answer is no. You could however provide proc surveyselect with a measure of the overall variance of your variables. The determinant of the covariance matrix of your variables can be considered as such an estimate of the overall variance. It can be calculated for each strata by proc discrim. Use ODS to transfer the information from discrim to surveyselect. This example shows you how:
proc sort data=sashelp.class out=myClass; by sex; run;
/* Get the determinant of the covariance matrix within each stratum */
ods select LogDet;
proc discrim data=myClass pool=no noclassify;
class sex;
var weight height age;
ods output LogDet=sexLogDet;
run;
/*
Output dataset sexLogDet includes variables
FromSex : name of sex group (M or F)
LogDet : logarithm of the determinant of the covariance matrix of each stratum
*/
/* Create table containing strata variances */
proc sql;
create table sexVar as
select
FromSex as sex length=1, /* Length must match variable in myClass dataset */
exp(LogDet) as _VAR_
from sexLogDet
order by sex;
quit;
proc surveyselect data=myClass out=mySample sampsize=5;
strata sex / alloc=Neyman var=sexVar;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.