Announcement

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

  • Egen with an if statement

    Hi,

    I have a long dataset with multiple observations per patient id. I’m trying to generate a medical claims payment variable by patient id for different claim types (outpatient, inpatient, etc) for a period of 30 days, 60 days, and 90 days. My variables are: totpay_line - the variable to be summed across all rows corresponding to an id; ClaimTyp_Crosswalk – a categorical variable that identifies different claim types; r30 - a binary variable where 1 implies that a claim is within the 30 day window; and id – patient id.
    Since I can’t use the if statement as in my code below, how can I do this without reshaping the data?

    Code:
    egen totpay_claim30 = sum(totpay_line), by(id ClaimTyp_Crosswalk) if r30==1
    Thanks,
    Karishma

    PS: I apologise for not using dataex to post a sample of the dataset. I am working off a remote server that doesn’t allow me to access the internet through it and I can’t copy the data outside of it.

  • #2
    the "if" clause goes prior to the comma, not after it

    Comment


    • #3
      Thank you, Rich.

      Comment

      Working...
      X