在sas

ath*_*esh 3 sas

我将以下数据集作为输入

ID  
--  

1  
2  
2  
3  
4  
4  
4  
5  
Run Code Online (Sandbox Code Playgroud)

并需要一个新的数据集如下

ID   count of ID  
--   -----------

1    1  
2    2  
3    1  
4    3  
5    1  
Run Code Online (Sandbox Code Playgroud)

您能告诉我如何使用PROC SQL在SAS中执行此操作吗?

Lon*_*ish 7

或者如何处理Proc Freq或Proc Summary?这些避免了必须预先分配数据.

proc freq data=have noprint;
table id / out=want1 (drop=percent);
run;

proc summary data=have nway;
class id;
output out=want2 (drop=_type_);
run;
Run Code Online (Sandbox Code Playgroud)


小智 5

proc sql noprint;
create table test as select distinct id, count(id)
from your_table
group by ID
order by ID
;
quit;
Run Code Online (Sandbox Code Playgroud)