DATA Step, Macro, Functions and more

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

Reply
Occasional Contributor
Posts: 17

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,401

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

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,083

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

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
  • 95 views
  • 0 likes
  • 3 in conversation