11-15-2017 04:50 PM
The code below creates a unique count of the variable y for each value of x and a summary row. However, it requires two queries and a data step. Is there a way to all in one query?
input x $1. y 1.;
create table b as select x, n(distinct y) as y_cnt
group by x;
create table c as select 'Total' as x, n(distinct y) as y_cnt
length x $5;
set b c;
11-15-2017 05:29 PM
Do your records overlap within X/ by group?
ie If you sum the total from the summary total are you expecting it to add to the total, or do you need a separate distinct count because of the overlap?
If you need that distinction I can't think of an alternative
Hopefully someone else can, so partially responding to see if there is a solution to this problem.