Announcement

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

  • Collapsing data - factor variables not allowed r (101)

    Hello Statalist,

    Let me introduce myself - I'm a beginner in the Stata world and would kindly ask for some assistance regarding a question I have.

    I'd like to collapse the variable ilos_sum by 4 other variables (periodid code16n ndf patienthash).

    To that end my steps are as follows:

    collapse (sum) ilos_sum by(periodid code16n ndf patienthash)

    To which I get factor variables not allowed r (101)

    I've attempted several other approaches, including:
    egen long aggregated=group(periodid code16n ndf patienthash) //grouping
    collapse (sum) ilos_sum by(aggregated) //final aggregation

    Unfortunately I could not find the necessary information to the best of my abilities in the forum or other sources. Everywhere we had aggregation by one variable only.

    Thank you!




  • #2
    Ivan:
    welcome to the list.
    As far as I can get it, a comma is probably missing in your temptative code.
    Try, instead:
    Code:
    collapse (sum) ilos_sum, by(periodid code16n ndf patienthash)
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Ivan:
      welcome to the list.
      As far as I can get it, a comma is probably missing in your temptative code.
      Try, instead:
      Code:
      collapse (sum) ilos_sum, by(periodid code16n ndf patienthash)
      Thank you very much, Carlo! Appreciate the help.

      Comment

      Working...
      X