Announcement

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

  • Generating a new variable that contains only some values of other variables

    Dear all,

    I have a set of variables (i.e., v1 to V) from which I would like to extract some single summarized data (i.e., the median). With the data retrieved from each variable, I would like to generate a new single variable that keeps the summarized data organized in several observations (as the number of variables).

    Any idea on how to proceed?

    Thank you in advance.

  • #2
    This sounds like a job for collapse or egen. So you could do the following:
    Code:
    sysuse auto, clear
    egen medprice = median(price)
    You could then write a loop and iterate over all variables of interest.
    Best wishes

    (Stata 16.1 MP)

    Comment


    • #3
      Thank you, Felix, I will try this way.

      Comment

      Working...
      X