Announcement

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

  • Recoding a variable from panel dataset with duplicate identifiers

    Hi everyone.

    I am currently working on my thesis, covering gender and decision-making in South Africa's National Income Dynamics Study. I wanted some advice on how I can code the decision-making variable, in the face of duplicates.

    In the survey, respondents were asked for the PID / identifier code of the person in the household who is the main decision-maker. I want to recode this variable to represent the gender of the decision-maker. However, when I run this code:

    Code:
    g decisiongender=0 if decisionmaker!=. & female==0 //male
    replace decisiongender=1 if decisionmaker!=. & female==1 // female
    label var decisiongender "decisionmakergender"
    label val decisiongender decisiongender_dummy
    label define decisiongender_dummy 0 "male" 1 "female"
    The results represent the gender of the person responding, not the gender of the person that was nominated as the decision-maker.

    I attempted a different solution by running the following:

    Code:
    preserve
    
    keep pid female
    
    rename (pid female) (decisionpid decisionfemale)
    
    save "dec.dta", replace
    
    restore
    
    merge m:1 decisionpid using "dec.dta"
    drop _merge
    tab decisionfemale
    However, I received the following error:
    Code:
    variable decisionpid does not uniquely identify observations in the using data
    r(459);
    I believe this is due to the fact of the data being a panel and having multiple responses for each PID over the multiple waves of the survey, as well as the survey allowing for a PID to be represented in multiple households. Dropping the duplicate PIDs will not aid my analysis.
    Does anyone have any advice on how I could recode this variable? I am fairly new to Stata so there may be an obvious solution I do not know.
    Thanks!

  • #2
    Romy:
    without an example/excerpt of your dataset, to be provided via -dataex- (as per FAQ), I find difficult to reply positively. Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X