Announcement

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

  • Help for reading in "nlswork5_xtrccipw" dataset

    I am potentially interested in using the package "xtrccipw" to perform pattern-mixture analysis on longitudinal data and want to work through some examples. The examples are all from the "nlswork5_xtrccipw" dataset, with code to build in the appendix here: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5947963/. When I cut and paste the code (from the pdf, the website, and ePub), I get the error "` invalid name
    r(198);" after the below chunk of code:

    foreach outcomevar in union {
    generate _firstyearRD1`outcomevar´ = (`outcomevar´ < .)
    generate firstyearRD1`outcomevar´ = .
    replace firstyearRD1`outcomevar´ = _firstyearRD1`outcomevar´ ///
    if (yearidx == 1)
    replace firstyearRD1`outcomevar´ = ///
    _firstyearRD1`outcomevar´ * firstyearRD1`outcomevar´[_n−1] ///
    if (yearidx > 1)
    drop _firstyearRD1`outcomevar´
    rename firstyearRD1`outcomevar´ RD`outcomevar´
    replace `outcomevar´ =. if (RD`outcomevar´ == 0)
    }

    I do not want to alter the dataset because I want to use it to learn - does anyone know what is causing this error and how to fix?

    Thank you very much,
    Anne

  • #2
    There seems to be an issue with your rightmost macro quotes. This could be caused by copying to a text editor, or it might be related to how they are rendered in the PDF document. Try the following:

    Code:
    foreach outcomevar in union {
    generate _firstyearRD1`outcomevar' = (`outcomevar' < .)
    generate firstyearRD1`outcomevar' = .
    replace firstyearRD1`outcomevar' = _firstyearRD1`outcomevar' ///
    if (yearidx == 1)
    replace firstyearRD1`outcomevar' = ///
    _firstyearRD1`outcomevar' * firstyearRD1`outcomevar'[_n−1] ///
    if (yearidx > 1)
    drop _firstyearRD1`outcomevar'
    rename firstyearRD1`outcomevar' RD`outcomevar'
    replace `outcomevar' =. if (RD`outcomevar' == 0)
    }

    Comment

    Working...
    X