Announcement

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

  • Creating a categorical variable based on observations

    I want to create a new categorical variable that will have 5 categories based on groupings of observations. For example, fees = 5 will include observations 11769/12911 & 18862/19769 and a similar approach for the other categories. I'm not sure on how to create all 5 categories?

  • #2
    Ajay:
    without further details, I would go step-by-step following a safe but inefficient way:
    Code:
    g wanted=5 in 11769/12911
    replace wanted=5 in 18862/19769
    ...and the -replace- festival will go on and on until you reach the lower bound of your ranking.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Carlo Lazzaro is bang on in terms of the question asked. I would add that

      1. Specifying such a new variable depends sensitively on the current sort order.

      2. It's essential to document why these observations are used and indeed almost always better practice to have a rule for generate and replace that is more explicit.

      Comment

      Working...
      X