Announcement

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

  • Cross-references between different variables

    Dear Stata ist members,

    I am quite a new STATA user, so maybe I simply do not know the right keywords to search for solutions to this question. In that case please forgive me if I am posting a very simple question.

    I have a household survey dataset containing a variable for Household ID ("IH01", between 1-2000) and a variable household member ID within the household ("HM00", between 1-20). So hh members are identified by their household ID and their member ID.
    Moreover, I have a variable that indicates the member ID of the household member who decides about the useage of the income that a different household member earned (JB02f).
    Lastly, I have a variable for the sex of each household member (HM03_).
    I now want to generate a new variable JB02f_sex which indicates for the household member that earned the income, what the sex of the second person is who decides about that first household member's income.


    I imagine the code would have to look sort of like this:

    gen JB02fsex=.
    bysort IH01, replace JB02fsex = HM03_ "FOR" HM00==JB02f

    My problem is that I do not now how to tell STATA that it should not take the sex of the household member who is earning the income but of the household member whose ID is equal to the one indicated in question JB02f (the "FOR" in my code below). Can anybody help me with this code?

  • #2
    Welcome to Statalist, Paula! Unfortuntely, this is the forum devoted to making test posts. ("sandbox" in English refers to a child's play area) Ask in the General Forum. Before you do, read the FAQ, especialy FAQ 12. You will be asked to show a snippest of a data listing and to put it and codes between CODE delimiters.

    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment

    Working...
    X