楼主: 邓贵大
1917 6

[有偿编程] Site Pooling [推广有奖]

  • 0关注
  • 18粉丝

博士生

59%

还不是VIP/贵宾

-

威望
0
论坛币
88 个
通用积分
2.1142
学术水平
182 点
热心指数
178 点
信用等级
166 点
经验
9462 点
帖子
296
精华
0
在线时间
335 小时
注册时间
2009-6-17
最后登录
2014-9-20

楼主
邓贵大 发表于 2013-11-20 23:02:31 |AI写论文
400论坛币
又有"钱"可以向大家请教了,是一个合并clinical sites的问题。
现有79个sites,它们的ID、邮编和病人总数如下。
  1. data sites;
  2. input siteid:$3. zip population;
  3. datalines;
  4. 101 76712 19
  5. 102 78229 24
  6. 103 19422 7
  7. 104 78233 1
  8. 105 27262 13
  9. 106 38401 8
  10. 107 95207 14
  11. 108 92691 19
  12. 109 55441 14
  13. 184 75234 7
  14. 110 31707 4
  15. 111 52240 4
  16. 112 23233 1
  17. 113 77450 6
  18. 114 14618 10
  19. 116 76712 16
  20. 117 73131 14
  21. 118 37919 25
  22. 119 27607 21
  23. 120 29303 8
  24. 121 68123 6
  25. 122 19103 6
  26. 123 92868 14
  27. 124 95117 3
  28. 125 11570 7
  29. 126 19115 8
  30. 127 45242 5
  31. 128 92123 13
  32. 129 80112 9
  33. 130 78130 27
  34. 131 84020 20
  35. 132 78209 16
  36. 133 78759 28
  37. 134 74136 12
  38. 135 78229 24
  39. 136 55402 13
  40. 138 63141 14
  41. 139 76109 1
  42. 141 48197 11
  43. 142 63031 2
  44. 143 75231 28
  45. 144 07059 12
  46. 145 79903 13
  47. 146 89052 6
  48. 147 21236 20
  49. 148 30281 10
  50. 149 90808 6
  51. 150 02747 14
  52. 151 61761 24
  53. 154 15241 8
  54. 155 44130 16
  55. 156 08558 19
  56. 157 07666 4
  57. 158 92024 24
  58. 159 40215 18
  59. 160 92120 14
  60. 161 29406 15
  61. 162 78229 32
  62. 163 37167 7
  63. 164 75231 20
  64. 165 80033 1
  65. 166 32308 1
  66. 167 30281 12
  67. 168 02906 14
  68. 169 07712 13
  69. 170 72205 7
  70. 171 37064 8
  71. 173 80907 16
  72. 174 90025 16
  73. 175 53228 15
  74. 177 80907 15
  75. 178 78731 28
  76. 180 59718 11
  77. 181 20902 10
  78. 182 43560 14
  79. 183 90048 3
  80. ;
复制代码
希望通过合并一些sites来达到每个site的最低病人数---20,大致步骤为:
(1)如果某个site人数不足20,则把它与离它最近的site合并,生成一个新site并删除原来俩sites;
(2)如果(1)之后所有site都够20人了,终止;
(3)如果合并过的site还是不够20人,重复(1)。
site间的距离根据sashelp.geocode里提供的经纬度算,合并过的site的经纬度按合并前俩sites的经纬度平均(没什么好办法)。
你可以自己规定一个顺序保证结果唯一。
因为一般不会超过1000个sites,所以效率不是问题,在下这个粗人只要求程序简单易懂。

最佳答案

吕小布韦 查看完整内容

proc sort data=sites out=sort; by zip; run; data a; set sashelp.zipcode; keep zip x y; run; data b; merge a(in=ina) sort(in=insort); by zip; if insort; run; proc sort data=b out=b1; by population; run; data b2; length site $30.; x1=0; y1=0; site='0'; population1=0; n=0; set b1; if population>=20 then output; else do; do while(population1
关键词:Pooling Site POOL ING sit clinical
已有 1 人评分经验 论坛币 收起 理由
webgu + 100 + 100 给你加点币

总评分: 经验 + 100  论坛币 + 100   查看全部评分

Be still, my soul: the hour is hastening on
When we shall be forever with the Lord.
When disappointment, grief and fear are gone,
Sorrow forgot, love's purest joys restored.

沙发
吕小布韦 发表于 2013-11-20 23:02:32
proc sort data=sites out=sort;
by zip;
run;

data a;
set sashelp.zipcode;
keep zip x y;
run;

data b;
merge a(in=ina) sort(in=insort);
by zip;
if insort;
run;
proc sort data=b out=b1;
by  population;
run;
data b2;
length site $30.;
x1=0;
y1=0;
site='0';
population1=0;
n=0;
set b1;        if population>=20 then output;
else
do;
do while(population1<20);
set b1;
population1=(population1+population);
x1=sum(x1,x);
y1=sum(y1,y);
n=n+1;
end;
x1=x1/n;
y1=y1/n;
output;
end;
;
keep x1 y1 population1 zip;
run;
坐等被优化...如果值得优化的话..局限性如下: 不知道那几个site合并起来了; 首先按照pop排序的, 所以前面几个比较小pop的合并在了一起,

藤椅
webgu 发表于 2013-11-21 08:37:39
你这里没有经纬度信息啊。
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

板凳
邓贵大 发表于 2013-11-22 11:56:46
webgu 发表于 2013-11-21 08:37
你这里没有经纬度信息啊。
说错了,是从sashelp.zipcode里面取。
另外,拜托别给我easy money啦
Be still, my soul: the hour is hastening on
When we shall be forever with the Lord.
When disappointment, grief and fear are gone,
Sorrow forgot, love's purest joys restored.

报纸
邓贵大 发表于 2013-11-22 11:57:57
吕小布韦 发表于 2013-11-20 23:02
proc sort data=sites out=sort;
by zip;
run;
谢谢,你是唯一的参与者,所以就是最佳的。
Be still, my soul: the hour is hastening on
When we shall be forever with the Lord.
When disappointment, grief and fear are gone,
Sorrow forgot, love's purest joys restored.

地板
webgu 发表于 2013-11-22 15:51:28
邓贵大 发表于 2013-11-22 11:56
说错了,是从sashelp.zipcode里面取。
另外,拜托别给我easy money啦
NOT EASY MONEY, BUT SOME COMPENSATION.
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

7
吕小布韦 发表于 2013-11-22 21:12:10
吕小布韦 发表于 2013-11-20 23:02
proc sort data=sites out=sort;
by zip;
run;
谢谢对这个程序的认可...但愿有新问题再发上来大家继续讨论学习!

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-4 01:54