For your Excel data, show what you would expect as the output.
@freda wrote:
Hi, dear all,
Thank you first for helping me with this problem.
I want to create a new variable calculating the following equation:
X=sum {min(dt_sold(i), dt_sold(j)) - max(dt_cre(i), dt_sold(j))} if dt_sold(i) or dt_sold(j) is missing, use dt_exp(i) or dt_exp(j) instead.
i and j are the unique id number of each transaction, and i does not equal to j.
I expect to run i from 1 to N and j from 1 to N.
transaction j has to satisfy other condition such as d_fsa (i) = d_fsa (j).
proc sql;
create table table1 as
select unique la1.*, sum(min(la1.date_sold, past1.date_sold)-max(la1.date_cre, past1.date_cre)) as o1
from la1
left join
la1 past1
on (la1.d_fsa=past1.d_fsa)
group by 1
order by 1 ;
quit;
I try my best to write the above code, but I know it is wrong.
Can anyone help me with the code.
Thank you so much
Best,
Freda
... View more