Code:
* Example generated by -
dataex-. For more info, type help dataex
clear
input float(a b c d g)
1 . . . 1
. . 1 . 1
1 . . . 2
. . 1 . 2
. 1 . . 3
1 . . . 3
. 1 . . 4
. . 1 . 4
1 . . . 4
1 . . . 5
. 1 . . 5
. . 1 . 5
1 . . . 6
. 1 . . 6
. . 1 . 6
. . . 1 6
end
a b c d four variables and g is the group variable
How to impute missing values?
The rule of interpolation is to interpolate the variable a b c d by group (g), and fill in the value of the variable (all 1) by group. When a variable appears 1, the other records in the group of this variable are all 1. , When a variable does not appear 1, other records in the group of this variable are all 0

The result I expect is as follows
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float(a b c d g)
1 0 1 0 1
1 0 1 0 1
1 0 1 0 2
1 0 1 0 2
1 1 0 0 3
1 1 0 0 3
1 1 1 0 4
1 1 1 0 4
1 1 1 0 4
1 1 1 0 5
1 1 1 0 5
1 1 1 0 5
1 1 1 1 6
1 1 1 1 6
1 1 1 1 6
1 1 1 1 6
end
Looking forward to your help,thank you very much,