BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Vltava
Calcite | Level 5
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!
1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

View solution in original post

1 REPLY 1
PGStats
Opal | Level 21

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 1 reply
  • 1617 views
  • 2 likes
  • 2 in conversation