SAS 改变随机样本的比例 [英] SAS Change the Proportion of a Random Sample

查看:62
本文介绍了SAS 改变随机样本的比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在随机抽样中改变和操纵SAS中一个变量的比例?

Is there a way to change and manipulate the proportion of a variable in SAS in random sampling?

假设我有一张可容纳 1000 人的桌子.(500男500女)

Lets say that I have table consisting 1000 people. (500 male and 500 female)

如果我想随机抽取 100 个具有性别分层的样本 - 我的输出中将有 50 个男性和 50 个女性.

If I want to have a random sample of 100 with gender strata - I will have 50 males and 50 females in my output.

我想了解是否有办法获得所需的性别值比例?

I want to learn if there is a way to have the desired proportion of gender values?

我可以随机抽取 100 个样本,其中包含 70 个男性和 30 个女性吗?

Can ı have a random sample of 100 with 70 males and 30 females ?

推荐答案

PROC SURVEYSELECT 是做到这一点的方法,使用 nsamprate 的数据集 而不是数字.

PROC SURVEYSELECT is the way to do this, using a dataset for n or samprate instead of a number.

data strata_to_Sample;
  length sex $1;
  input sex $ _NSIZE_;
datalines;
M 70
F 30
;;;;
run;
proc sort data=strata_To_sample;
  by sex;
run;

data to_sample;
  set sashelp.class;
  do _i = 1 to 1e5;
    output;
  end;
run;
proc sort data=to_Sample;
  by sex;
run;

proc surveyselect data=to_sample n=strata_to_sample out=sample;
  strata sex;
run;

这篇关于SAS 改变随机样本的比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆