2017-04-12 54 views
0

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

+1

[SAS更改随机抽样的比例(可能的重复http://stackoverflow.com/问题/ 36910853/sas-change-the-proportion-of-a-random-sample) – user667489

回答

2

要做到分层抽样,您可以使用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; 

希望这有助于:-)

+0

谢谢!我被要求在目标群体被选中后做到这一点。我不认为我可以在SAS中做到这一点?插入某些特征的百分比,然后让SAS根据这些百分比对总体进行抽样?尽管非常感谢您的回答,但您的回答非常有帮助! – Annita