楼主: 一眼瞬间
1928 4

有条件的随机选择,用sas怎么实现呢? [推广有奖]

  • 0关注
  • 1粉丝

讲师

50%

还不是VIP/贵宾

-

威望
0
论坛币
730 个
通用积分
0.0001
学术水平
0 点
热心指数
4 点
信用等级
0 点
经验
903 点
帖子
376
精华
0
在线时间
309 小时
注册时间
2010-3-14
最后登录
2023-8-19

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
RT。
基本数据类似如下特征:
SIC         Company      Year       Other Varaibles
001         A                   1991
001         A                   1992
001         A                   1993
001         A                   1994
289         B                   1991
289         B                   1992
289         B                   1993
289         B                   1994
333         C                   1991
289         C                  1992
289         C                  1993
289         C                  1994
001         D                   1991
001         D                   1992
001         D                   1993
001         D                   1994

以上数据每个公司有很多个年,用什么方法才能随机的每个公司只留下一个observation呢?

谢谢了!!!
这个和我另外一个问题其实是一样的,但是感觉上一个问的有点混乱。所以重新开一贴问,请版主见谅。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:observation observat company compan Other 选择 SAS 条件 随机

回帖推荐

jingju11 发表于2楼  查看完整内容

You can find the output data set of 'SampleStrata' is what you need. In fact, the variable SIC is not useful since the variable COMPANY is(looks like) unique in your data set. On the other hand, including SIC into strata is no harm here. You need to know that SIC + COMPANY must be unique. JingJu

本帖被以下文库推荐

沙发
jingju11 发表于 2010-3-15 04:55:02 |只看作者 |坛友微信交流群
一眼瞬间 发表于 2010-3-15 03:41
RT。
基本数据类似如下特征:
SIC         Company      Year       Other Varaibles
001         A                   1991
001         A                   1992
001         A                   1993
001         A                   1994
289         B                   1991
289         B                   1992
289         B                   1993
289         B                   1994
333         C                   1991
289         C                  1992
289         C                  1993
289         C                  1994
001         D                   1991
001         D                   1992
001         D                   1993
001         D                   1994

以上数据每个公司有很多个年,用什么方法才能随机的每个公司只留下一个observation呢?

谢谢了!!!
这个和我另外一个问题其实是一样的,但是感觉上一个问的有点混乱。所以重新开一贴问,请版主见谅。

  1. proc sort out = As; by sic company;
  2. run;
  3. proc surveyselect data=As
  4.          method=srs n=1
  5.          seed=11 out=SampleStrata(drop = SelectionProb) noprint;
  6.       strata sic company;
  7.    run;
复制代码

You can find the output data set of 'SampleStrata' is what you need.
In fact, the variable SIC is not useful since the variable COMPANY is(looks like) unique in your data set. On the other hand, including SIC into strata is no harm here. You need to know that SIC + COMPANY must be unique.
JingJu
已有 2 人评分经验 论坛币 学术水平 热心指数 收起 理由
bakoll + 3 + 3 精彩帖子
醉_清风 + 1 + 1 学习了

总评分: 经验 + 3  论坛币 + 3  学术水平 + 1  热心指数 + 1   查看全部评分

使用道具

藤椅
一眼瞬间 发表于 2010-3-15 06:27:58 |只看作者 |坛友微信交流群
jingju11 发表于 2010-3-15 04:55
一眼瞬间 发表于 2010-3-15 03:41
RT。
基本数据类似如下特征:
SIC         Company      Year       Other Varaibles
001         A                   1991
001         A                   1992
001         A                   1993
001         A                   1994
289         B                   1991
289         B                   1992
289         B                   1993
289         B                   1994
333         C                   1991
289         C                  1992
289         C                  1993
289         C                  1994
001         D                   1991
001         D                   1992
001         D                   1993
001         D                   1994

以上数据每个公司有很多个年,用什么方法才能随机的每个公司只留下一个observation呢?

谢谢了!!!
这个和我另外一个问题其实是一样的,但是感觉上一个问的有点混乱。所以重新开一贴问,请版主见谅。

  1. proc sort out = As; by sic company;
  2. run;
  3. proc surveyselect data=As
  4.          method=srs n=1
  5.          seed=11 out=SampleStrata(drop = SelectionProb) noprint;
  6.       strata sic company;
  7.    run;
复制代码
You can find the output data set of 'SampleStrata' is what you need.
In fact, the variable SIC is not useful since the variable COMPANY is(looks like) unique in your data set. On the other hand, including SIC into strata is no harm here. You need to know that SIC + COMPANY must be unique.
JingJu
So talented. Thanks so much, Jingju!

使用道具

板凳
醉_清风 发表于 2010-3-15 18:50:56 |只看作者 |坛友微信交流群
学习了 surveyselect 平时用的很简单 刚才看了下 sas help 还是有很多内容啊
从来不需要想起 永远也不会忘记

使用道具

报纸
爱萌 发表于 2010-3-16 10:15:58 |只看作者 |坛友微信交流群
很不错,用分层就可以了
最恨对我说谎或欺骗我的人

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-8 11:04