Hi @KurtBremser I am back on this string. I do need help with the complete solution. Right now, this code works for me that is edited from your first code.
proc sql;
create table want as
select characteristic, count(distinct id) as n
from have
group by characteristic;
quit;
However, I need the denominator to be the 'total number of distinct ids' to get the percent. How can I accomplish that as a nested select program in sql?
so basically I need :
proc sql;
create table want2 as
select count (distinct id) as n2
from have /* original dataset*/
quit;
so this count of distinct ids are not grouped by characteristic and my percent needs to be
n/n2*100
Hope this makes sense.
I have my code as this but I know there is something missing in it
proc sql;
create table want as
select a.characteristic, a.n, b.n2
from (select characteristic, count(distinct id) as n from have group by ccs2)
(select count(distinct id) as n2 from have) b;
quit;
So I want the three columns in the final dataset characteristic, n, n2, percent
and just to expand the data:
id
characteristic
id1
RDD
id1
TSS
id2
TSS
id2
RDD
id2
GGG
id2
HHH
So the output dataset will be
Characteristic
N
N2
%
RDD
2
2
100
TSS
2
2
100
GGG
1
2
50
HHH
1
2
50
Hope this makes it all clear. Look forward to your reply.
... View more