Desktop productivity for business analysts and programmers

Distinct SUM/COUNT on ID

Reply
Occasional Learner
Posts: 1

Distinct SUM/COUNT on ID

Hi, this i my first post, so here goes..

I'm trying to sum a column based on the DistinctID of the different column  where the value should only me visible on one of the rows (see attachment)

I want to do this for several columns but I cant figure out how to do it.

I have attached the current dataset and how the data should look like.

 

Any help would be appriciated!

 

PROC Star
Posts: 1,333

Re: Distinct SUM/COUNT on ID

Lots of people on this forum will help you out, but most of us won't open Excel files because of malware and corporate policies. See the posts for new users, there are different ways to present your data to let us work with it easily.

 

Welcome to SAS!

   Tom

Esteemed Advisor
Posts: 5,614

Re: Distinct SUM/COUNT on ID

Do it one ID as a time with something like this:

 

proc sort data=have; by id_01; run;

data want_01;
set have; by id_01;
if not last.id_01 then do;
	number_01 = 0;
	end;
run;

resort want_01 by id_02 and generate want_02, and so on... 

PG
Ask a Question
Discussion stats
  • 2 replies
  • 298 views
  • 0 likes
  • 3 in conversation