在 sas 中分组 [英] group by in sas
本文介绍了在 sas 中分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下数据集作为输入
I've the below dataset as input
ID
--
1
2
2
3
4
4
4
5
并且需要一个新的数据集如下
And need a new dataset as below
ID count of ID
-- -----------
1 1
2 2
3 1
4 3
5 1
能否请您告诉如何在 SAS 中不使用 PROC SQL 来执行此操作?
Could you please tell how to do this in SAS wihtout using PROC SQL?
推荐答案
试试这个:
DATA Have;
input id ;
datalines;
1
2
2
3
4
4
4
5
;
Proc Sort data=Have;
by ID;
run;
Data Want;
Set Have;
By ID;
If first.ID then Count=0;
Count+1;
If Last.ID then Output;
Run;
这篇关于在 sas 中分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文