Hello!

I am relatively new to Stata, and I am stuck on a hopefully easy-to-solve issue.

In my dataset individuals are uniquely identified by hhid and id. I am interested in whether these individuals, a) have a savings account and b) if so, they have a mobile money savings account.

My current data looks like the following, where
savingsacc==1 -> commercial savings account,
savingsacc==4 -> mobile money savings account
savingsacc==0 -> no savings account

Code:
hhid    id      savingsacc     mobmoney
1        4            1            .
1        4            4            1
1       10            0            .
3        1            1            .
3        2            1            .
3        2            4            1
Here, individual 1_4 has both a commercial and mobile money account, 1_10 has no account, 3_1 has only a commercial account and 3_2 again has both accounts.

In order to merge this with another dataset using hhid id, I need the data to look like the following, with savingsacc and mobmoney converted into simple yes/no dummies.

Code:
hhid    id      savingsacc     mobmoney
1        4            1            1
1       10            0            0
3        1            1            0
3        2            1            1
I am not sure how to deal with the fact that individuals appear twice in the data.

Thank you in advance for your help!

Best,
Sophia