0

我有一个具有某些特征的目标人群,我被要求根据这些特征选择适当的控制。我正在尝试使用 SAS 基础进行分层样本,但我需要能够从我的目标定义我的 4 starta %s 并将这些应用于我的样本。有什么办法可以做到吗?谢谢!

4

1 回答 1

2

To do stratified sampling you can use PROC SURVEYSELECT

Here is an example:-

/*Dataset creation*/

data data_dummy;
input revenue revenue_tag Premiership_level;
   datalines;
1000 High 1
90 Low 2
500 Medium 3
1200 High 4
;
run;


/*Now you need to Sort by rev_tag, Premiership_level (say these are the 
 variables you need to do stratified sampling on)*/
proc sort data = data_dummy;
by rev_tag  Premiership_level;
run;



/*Now use SURVEYSELECT to do stratified sampling using 10% samprate (You can 
change this 10% as per your requirement)*/

/*Surveyselect is used to pick entries for groups such that , both the 
  groups created are similar in terms of variables specified under strata*/

     proc surveyselect data=data_dummy method = srs samprate=0.10
     seed=12345 out=data_control;
     strata rev_tag  Premiership_level;
     run;

/*Finally tag (if you want for more clarity) your 10% data as control 
group*/
     Data data_control;
     Set data_control;
     Group = "Control";
     Run;

Hope this helps:-)

于 2017-04-18T17:08:53.290 回答