Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73331

Reference one set of variables based on another set of variables

$
0
0
Hi,

The following data is a mini version of my dataset, it is a little difficult to explain what Im trying to do, apologies for the confusion in advance. Basically Im trying to replace the value 0 from variable sa to sz with the sum value of 2 variables(out of the 4 variables) from reta to retz given the condition of the two variables have the highest and second highest value in ratioa to ratioz
(i.e In the second row (where sa have a value of 0). Between ratioa to ratioz, ratioc and ratiob have the highest and second highest value, I would like to replace sa with the sum value of retc and retb)

Im new to stata could you please give me detailed clarification.

Thank you very much!
Chris

date a b c z sa sb sc sz reta retb retc retz ratioa ratiob ratioc ratioz
4/01/11 11.39 4.24 2.67 3.26 . . . . . . . . 0.996980134 1.007724306 1.015016126 1.00076748
5/01/11 11.24 4.19 2.63 3.23 0 0 0 0 -0.013169447 -0.011792453 -0.014981273 -0.009202454 0.985230335 0.996551267 0.999809892 0.992167078
6/01/11 11.14 4.16 2.61 3.22 0 0 0 0 -0.008896797 -0.007159905 -0.007604563 -0.003095975 0.977493121 0.990004726 0.992395394 0.989855512
7/01/11 11.18 4.3 2.65 3.27 0 1 1 1 0.003590664 0.033653846 0.01532567 0.01552795 0.982166356 1.022470544 1.007221573 1.005225939

Viewing all articles
Browse latest Browse all 73331

Trending Articles