Dear Stata experts,
I’m struggeling with Stata for my masterthesis and it would be great if you could help me.
My data consists of (ABS)bonds which belong to a specific deal/transaction (dealnr) and within the deal there is a certain order (order_)of the bonds. Now I’d like to find the subordinated volume (subvol_) for each bond within the deal. For example the subvol_ for the first bond should comprise the volume (vol) of the second and third bond within the deal; the subvol_ for the second bond is the volume of the third; and the subvol_ for the third bond is zero.
I tried:
sort dealnr order_
by dealnr: generate subvol_=sum(vol) if order_[n]>order_
…but I know there is something wrong.

The right column for subvol_ needs to be:
213
161,5
0
750
400
0
I'm grateful for any tips.
Thank you very much in advance.
I’m struggeling with Stata for my masterthesis and it would be great if you could help me.
My data consists of (ABS)bonds which belong to a specific deal/transaction (dealnr) and within the deal there is a certain order (order_)of the bonds. Now I’d like to find the subordinated volume (subvol_) for each bond within the deal. For example the subvol_ for the first bond should comprise the volume (vol) of the second and third bond within the deal; the subvol_ for the second bond is the volume of the third; and the subvol_ for the third bond is zero.
I tried:
sort dealnr order_
by dealnr: generate subvol_=sum(vol) if order_[n]>order_
…but I know there is something wrong.
The right column for subvol_ needs to be:
213
161,5
0
750
400
0
I'm grateful for any tips.
Thank you very much in advance.

Comment