Hello , Here is a data set have, The problem is I want new variable count_sub count the number of each type for each id, Please help. Thanks! data have; input id type $; cards; 1 A 1 A 1 A 1 B 2 A 2 B 2 B 2 C 2 C 2 C 2 C ; proc sql noprint; create table want_bad as select *,count(distinct type) as count_type,count(type) as count_sub from have group by id order by id,type ; quit; The dataset want should be like this: 1 A 2 3 1 A 2 3 1 A 2 3 1 B 2 1 2 A 3 1 2 B 3 2 2 B 3 2 2 C 3 4 2 C 3 4 2 C 3 4 2 C 3 4
... View more