Announcement

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

  • #16
    Pat, since parentfigure = 1 if the parent is a biological mother and 0 if the parent is a biological mother, then the command

    Code:
    list if parentfigure
    will list the observations corresponding to biological mothers. On the other hand,

    Code:
    list if !parentfigure & !missing(parentfigure)
    will list the observations of biological fathers. The negation character in Stata is the exclamation mark "!". Stata allows you to run a regression for a subsample using the if qualifier. Here is a reproducible example.

    Code:
    sysuse auto, clear
    *FULL SAMPLE
    regress price mpg weight
    
    *SAMPLE OF FOREIGN CARS
    regress price mpg weight if foreign
    
    *SAMPLE OF DOMESTIC CARS
    regress price mpg weight if !foreign
    So, as you see above, you can always do analysis on a subsample while the data is in long layout.




    Comment


    • #17
      Andrew: Thank you so much for your response. I read the "reshape long" information as you had suggested in a prior post, so no longer have the following syntax:
      expand 2, gen(x) gen X1HPAR= cond(x==0, X1HPAR1, X1HPAR2) gen parentfigure = cond(X1HPAR == 1, 1, cond(X1HPAR == 2, 0, .)) label define parentfigure 1 "BIOLOGICAL MOTHER" 0 "BIOLOGICAL FATHER" label values parentfigure parentfigure tab X1HPAR
      Instead I used this:
      reshape long X1HPAR, i(CHILDID) j(parentfigure) (note: j = 1 2)
      now parent figure =1 or =2 I then generated Mother's Education (and a number of other variables in a similar way) as follows:
      gen MOMED = X12PAR1ED_I if X1HPAR == 1
      (16,247 missing values generated)
      When I try to regress the variables that I created from X1HPAR as above (DADED),I get a message that there are no observations?

      I hope I have not confused you, I certainly have confused myself!

      Comment


      • #18
        Andrew: Also, I am not limiting my regression analysis to a subsample. I have a number of other variables that I created that are unrelated to those generated by using the X1HPAR variable.
        For example here is my regression command:
        reg ZX1MTHETK4 i.MOMDEG##i.DADDEG MOMAGE DADAGE MOMOSCR DADOSCR MOMWORK ///
        > DADWORK FEMALE CHILDAGE CHILDRACE i.SIBLINGS ///
        > KDGREPEAT NONENG SINGPAR PRIVATE i.PKCARE i.SCHLOCATE i.INCOME
        no observations
        r(2000);

        Comment

        Working...
        X