Solved
Regular Learner
Posts: 1

# proc surveyselect - OPTIMAL ALLOCATION

```In SURVEYSELECT you can requests optimal allocation, which allocates the total sample sizeamong 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! ```

Accepted Solutions
Solution
‎10-14-2015 03:35 AM
Posts: 5,050

## Re: proc surveyselect - OPTIMAL ALLOCATION

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;
``````

PG

All Replies
Solution
‎10-14-2015 03:35 AM
Posts: 5,050

## Re: proc surveyselect - OPTIMAL ALLOCATION

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;
``````

PG
🔒 This topic is solved and locked.