DATA Step, Macro, Functions and more

I want the sum value if id is repeating like in the attachment with proc sql

Reply
Contributor
Posts: 24

I want the sum value if id is repeating like in the attachment with proc sql


if ID is > 1 then sum of edate - stdate
else just retain the edate - stdate in varibale


support1.PNG
Super User
Super User
Posts: 7,942

Re: I want the sum value if id is repeating like in the attachment with proc sql

Posted in reply to SrikanthY

Post test data in the form of a datastep, and required output.  I am not here to type in test data to provide you code.

Super User
Posts: 5,499

Re: I want the sum value if id is repeating like in the attachment with proc sql

Posted in reply to SrikanthY

Based on your diagram, this looks like it might do the trick:

 

data want;

Rvalue=0;

do until (last.id);

   set have;

   by id;

   Rvalue + (edate - stdate);

end;

do until (last.id);

   set have;

   by id;

   subvalue = edate - stdate;

   output;

end;

run;

 

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