Announcement

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

  • Merging two rows in stata

    Hello Dear All,

    I am using DHS. This is household survey. Based on HHID and HV003 variables, I need to create a CASEID variable. My aim is to merge HH dataset and individual level dataset using CASEID as an identifer in my master dataset, which is individual level. Below, you can see the HH level dataset snapshot.

    Click image for larger version

Name:	1.png
Views:	1
Size:	4.0 KB
ID:	1664251


    Here, in the individual level dataset, the CASEID variable is already identified based on the HH dataset. It is the sum of HHID and HV003 as you can see. My question is, I would like to create a CASEID variable in the HH dataset by merging HHID and HV003 variables. However, I could not do this. Can you please help me? Please note that HV003 variable is from 1 to 12. So, I need my new CASEID variable look likes this; for example, 01010004 02, not 01010004 2. Thank you very much in advance
    Click image for larger version

Name:	2.png
Views:	1
Size:	3.1 KB
ID:	1664252



  • #2
    Perhaps something like the following will start you in a useful direction.
    Code:
    generate CASEID = HHID + " " + strofreal(HV003,"%02.0f")

    Comment


    • #3
      Originally posted by William Lisowski View Post
      Perhaps something like the following will start you in a useful direction.
      Code:
      generate CASEID = HHID + " " + strofreal(HV003,"%02.0f")
      Dear Professor, it worked. Thank you so much.

      Comment

      Working...
      X