Announcement

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

  • data already long..variable yydx already exists

    Hi I'm trying to use Paul Dickman's code

    Source:
    https://pauldickman.com/software/sta...e-standsurv.do

    However when I come to this section
    - The only thing I have tweaked is keeping yydx here - as I think it makes sense to keep it as it is then used to reshape

    Code:
    //reshape from wide to long to make plotting easier
    keep in 1
    keep id S_male* S_female* S_diff* yydx
    reshape long S_male S_male@_lci S_male@_uci S_female S_female@_lci S_female@_uci S_diff S_diff@_lci S_diff@_uci, i(id) j(yydx)

    I get the following error

    variable yydx already exists
    Data are already long.
    r(110);

    Any thoughts why this is happening?

  • #2
    Any thoughts why this is happening?
    It's happening for exactly the reason that Stata's error message tells you: yydx already exists. The name specified in the -j()- option of -reshape long- must be a new variable, not an existing one.

    I'm inferring from your code that the variables S_male, S_female, S_diff, and their corresponding _uci and *_lci variables are indexed by some number and you would like to change the organization to just single variables S_male, S_female, S_diff, S_uci, and S_lci, with that index number as a separate variable. You just have to pick a name for that variable, preferrably a descriptive one like "visit number" or "age_group" or whatever that is, and then put that name in the -j()- option. There is probably no need to mention yydx in the command at all.

    Comment

    Working...
    X