Hello respected stata community,

I have a dummy variable which takes the value 0 and 1. The observation for different counites are given below in a single year 2017. Here, the counties get repeated several times in a single year. I need to find the combined value of the variable length for each unique county of a unique state in a single year when dummy variable takes the value 1. And, if in any observation of a unique county never takes the value 1 , then the desired value of variable combined length will show zero.

Can anyone kindly tell me how I can do it ? I've thought for couple of days but havent come up with any efficient coding yet.

----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input int Year_Recor byte State_Code int County_Cod byte dummy float length
2017 1  89 0    .1
2017 1   1 1  .043
2017 1 123 0    .1
2017 1  45 0  .097
2017 1  97 0  .438
2017 1 123 0    .1
2017 1 117 1    .1
2017 1  25 0    .1
2017 1 123 1    .1
2017 1  51 0    .1
2017 1 123 0    .1
2017 1   3 0    .1
2017 1 115 0    .1
2017 1  71 0    .1
2017 1  77 0  .034
2017 1  61 0    .1
2017 1  39 0    .1
2017 1 125 0    .1
2017 1  59 0    .1
2017 1  15 0    .1
2017 1  89 1    .1
2017 1  81 1    .1
2017 1  77 0    .1
2017 1 127 0  .036
2017 1 103 0    .1
2017 1  49 0  .018
2017 1  81 0    .1
2017 1 101 0    .1
2017 1  91 0    .1
2017 1  91 0  .087
2017 1  49 1    .1
2017 1 115 0    .1
2017 1 107 0    .1
2017 1  89 0  .004
2017 1  43 0  2.22
2017 1  31 0    .1
2017 1  79 0 1.013
2017 1 125 1  .056
2017 1 117 0    .1
2017 1   3 1   .04
2017 1  49 1    .1
2017 1 125 1  .052
end