[Very sorry, text version can't figure it out the exact column. Please look at the photo file. I'm so sorry.]
I have a long type data like following;
hid pid rel sex marriage salary
1 101 1 1 1 300
1 102 2 0 1 0
2 201 1 1 1 0
2 202 2 0 1 250
2 203 3 1 0 0
3 301 1 1 1 350
3 302 2 0 1 450
where if rel=1 then husband, rel=2 wife, rel=3 children, and if sex=1 then male, sex=0 female.
In this case how can I get the differences between husband's and wive's salary, like following ;
differences
hid pid rel sex marriage salary A_type B_type C_type
1 101 1 1 1 300 300 300
1 102 2 0 1 0 -300 -300
2 201 1 1 1 0 -250 -250
2 202 2 0 1 250 250 250
2 203 3 1 0 0 0
3 301 1 1 1 350 -100 -100
3 302 2 0 1 450 100 100
The kind of types do not matter.
I have a long type data like following;
hid pid rel sex marriage salary
1 101 1 1 1 300
1 102 2 0 1 0
2 201 1 1 1 0
2 202 2 0 1 250
2 203 3 1 0 0
3 301 1 1 1 350
3 302 2 0 1 450
where if rel=1 then husband, rel=2 wife, rel=3 children, and if sex=1 then male, sex=0 female.
In this case how can I get the differences between husband's and wive's salary, like following ;
differences
hid pid rel sex marriage salary A_type B_type C_type
1 101 1 1 1 300 300 300
1 102 2 0 1 0 -300 -300
2 201 1 1 1 0 -250 -250
2 202 2 0 1 250 250 250
2 203 3 1 0 0 0
3 301 1 1 1 350 -100 -100
3 302 2 0 1 450 100 100
The kind of types do not matter.
Comment