如何在 SAS 中对数据集进行排序以使记录交错?
假设我有一个数据集:
data animals;
input animal $
group $
control $;
datalines;
dog A c1
dog B c1
dog C c1
dog D c2
dog E c2
dog F c2
dog G c3
dog H c3
dog I c3
;
run;
我希望以这样的方式对其进行排序,结果数据集如下所示:
dog A c1
dog D c2
dog G c3
dog B c1
dog E c2
dog H c3
dog C c1
dog F c2
dog I c3
我没有看到任何可以进行“交替”排序的过程排序的特殊选项,所以我可能不得不将我的数据集“通过控制”进行子集化,然后以交错/交替的方式在数据步骤中重新组合。
有什么想法吗?谢谢。
Suppose I have a dataset:
data animals;
input animal $
group $
control $;
datalines;
dog A c1
dog B c1
dog C c1
dog D c2
dog E c2
dog F c2
dog G c3
dog H c3
dog I c3
;
run;
I would like that to be sorted in such a way that the resulting dataset looks like:
dog A c1
dog D c2
dog G c3
dog B c1
dog E c2
dog H c3
dog C c1
dog F c2
dog I c3
I don't see any special options for proc sort that would do an "alternating" sort, so I will probably have to subset my dataset "BY control", then recombine in a data step in such a way that they interleave/alternate.
Any ideas? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)