Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Matching households food consumption with individual

    Dear Stata list,

    I have household level 24 hours food consumption data (by Menu) including ingredients in one data set.

    In another data set, for the same household, I also have individual level food consumption data only by Menu (no ingredients )

    How can I match two data sets to find out individual level ingredients consumed by each person.

    Below example data sets are given. I also do not know why example data sets are not working (very sorry about that)
    Household level data:

    clear
    input double hh_id int Menu_1 int ingre_1 int ingre_2 int ingre_3 int ingre_4 int ingre_5

    1 "Salt"
    1 "Rice/Jao" "Fine Rice"
    1 "Jhol curry" "Lau Shak" "Koi" "Potato" "Turmeric"
    1 "Bhuna curry" "Potato" "Onion" "Garloic" "Coriander"
    1 "Supari"
    1 "Betel Leaf"
    2 "Rice/Jao"
    2 "Bhuna corry" "Water gourd" "Tengra" "Onion" "Green chilli"
    2 "Salt"
    end

    Individual level data:

    input double hh_id double Person_id double age int Menu_2
    1 1 . "Salt"
    1 1 57 "Rice/Jao"
    1 1 . "Bhuna curry"
    1 2 50 "Rice/Jao"
    1 2 . "Bhuna curry"
    1 2 . "Jhol curry"
    2 1 . "Salt"
    2 1 51 "Rice/Jao"
    2 1 . "Bhuna curry"
    end

    Any support would highly appreciated !

    Thank you so much!

  • #2
    The only real obstacle here is that the variable containing the menu is named differently in the two data sets.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(hh_id Person_id age) str11 Menu_2
    1 1  . "Salt"       
    1 1 57 "Rice/Jao"   
    1 1  . "Bhuna curry"
    1 2 50 "Rice/Jao"   
    1 2  . "Bhuna curry"
    1 2  . "Jhol curry" 
    2 1  . "Salt"       
    2 1 51 "Rice/Jao"   
    2 1  . "Bhuna curry"
    end
    tempfile consumption
    save `consumption'
    
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte hh_id str11(Menu_1 ingre_1) str6 ingre_2 str7 ingre_3 str12 ingre_4 str1 ingre_5
    1 "Salt"        ""            ""       ""        ""             ""
    1 "Rice/Jao"    "Fine Rice"   ""       ""        ""             ""
    1 "Jhol curry"  "Lau Shak"    "Koi"    "Potato"  "Turmeric"     ""
    1 "Bhuna curry" "Potato"      "Onion"  "Garloic" "Coriander"    ""
    1 "Supari"      ""            ""       ""        ""             ""
    1 "Betel Leaf"  ""            ""       ""        ""             ""
    2 "Rice/Jao"    ""            ""       ""        ""             ""
    2 "Bhuna corry" "Water gourd" "Tengra" "Onion"   "Green chilli" ""
    2 "Salt"        ""            ""       ""        ""             ""
    end
    tempfile recipes
    save `recipes'
    
    use `consumption', clear
    clonevar Menu_1 = Menu_2
    merge m:1 hh_id Menu_1 using `recipes'
    drop Menu_1
    Please re-read the help file for the -dataex- command and follow those instructions when posting example data in the future. If you don't find those instructions helpful, David Benson has a nice video at https://youtu.be/bXfaRCAOPbI.

    Comment


    • #3
      Dear Clyde,

      Thank you so much for the details input!

      I do not know why the syntex (use `consumption', clear) does not work in my data set whether due to data type. it gives a message as below
      invalid file specification.

      May I know what can I do with that.

      Thank you

      Comment


      • #4
        Thank you so much Clyde! It works now!

        Comment

        Working...
        X