Announcement

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

  • xcollapse or collapse

    Thanks, Nick for the advice on labelling.

    But now I have another problem. When I type:


    . . fsum WP10593 WP106 WP11362 WP12230 WP12231 WP12232 WP12451 WP12471 WP12472 WP12473 WP128 WP130 movebe
    > tterliving moveimproveliving movegoodjob movenojobhome movekidfuture movehumanrights moveenvironment mo
    > vesocialbenefits moveclosefamily WP10593

    i get:

    Variable | N Mean SD Min Max
    --------------------+---------------------------------------------
    WP10593 | 1778 0.38 0.49 0.00 1.00
    WP106 | 2063958 1.53 0.70 1.00 4.00
    WP11362 | 35469 3.55 1.38 1.00 7.00
    WP12230 | 32706 0.55 0.50 0.00 1.00
    WP12231 | 33000 1.55 0.51 1.00 4.00
    WP12232 | 33000 1.10 0.33 1.00 4.00
    WP12451 | 4498 8.48 22.07 1.00 99.00
    WP12471 | 21458 1.34 0.61 1.00 4.00
    WP12472 | 21458 1.92 0.65 1.00 4.00
    WP12473 | 17394 1.55 0.70 1.00 4.00
    WP128 | 1860168 1.27 0.54 1.00 4.00
    WP130 | 2167387 1.35 0.55 1.00 4.00
    movebetterliving | 4498 0.31 0.46 0.00 1.00
    moveimproveliving | 4498 0.26 0.44 0.00 1.00
    movegoodjob | 4498 0.09 0.29 0.00 1.00
    movenojobhome | 4498 0.03 0.16 0.00 1.00
    movekidfuture | 4498 0.13 0.33 0.00 1.00
    movehumanrights | 4498 0.03 0.17 0.00 1.00
    moveenvironment | 4498 0.01 0.07 0.00 1.00
    movesocialbenefits | 4498 0.03 0.18 0.00 1.00
    moveclosefamily | 4498 0.04 0.20 0.00 1.00
    WP10593 | 1778 0.38 0.49 0.00 1.00


    I then type:
    I
    . xcollapse WP10593 WP106 WP11362 WP12230 WP12231 WP12232 WP12471 WP12472 WP12473 WP128 WP130 movebett
    > erliving moveimproveliving movegoodjob movenojobhome movekidfuture movehumanrights moveenvironment move
    > socialbenefits moveclosefamily WP10593, by(country) saving("d:\data\gallupjan2024newiv.dta")
    error:
    WP10593 = (mean) WP10593
    WP10593 = (mean) WP10593
    name conflict

    or . collapse WP10593 WP106 WP11362 WP12230 WP12231 WP12232 WP12471 WP12472 WP12473 WP128 WP130 movebette
    > rliving moveimproveliving movegoodjob movenojobhome movekidfuture movehumanrights moveenvironment moves
    > ocialbenefits moveclosefamily WP10593, by(country)
    error:
    WP10593 = (mean) WP10593
    WP10593 = (mean) WP10593
    name conflict
    r(198);


    I get the same fsum after the collapse and when I type

    . fsum WP10593

    I get

    Variable | N Mean SD Min Max
    ----------+---------------------------------------------
    WP10593 | 1778 0.38 0.49 0.00 1.00

    Something is going on, I should get one observation for each country. What is the source of the problem. Thanks, Ric


  • #2
    I have also tried egen and contract and cannot find a way to get results by country,

    Comment


    • #3
      As for getting the same results from -fsum- "after -collapse-," this is happening because -collapse- has not actually run: it gave you an error message and left your data set as it was at the start. This is true of most Stata commands: if they halt with an error, they do not create any results and leave you in the state where you started.

      I am not familiar with -xcollapse-, which I suppose is a user-written variant of Stata's official -collapse- command. Suffice it to say that the problem with your -collapse- command is that the variable WP10593 is listed twice in the varlist, once at the beginning and once at the end. If you just remove one of them, I see no reason that -collapse- will not work. And I would conjecture the same is true for -xcollapse-.

      Comment


      • #4
        Thanks. Sorry for the duplication.

        Comment

        Working...
        X