Announcement

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

  • Using means of multiple variable to create new variable

    Hi,

    I want to use the mean of multiple variables to create a new variable containing the means of the different variables. I also want to be able to use the new variable to perform calculations , will Stata still be to identify the original source of the means ?

    Any help would be greatly appreciated.

  • #2
    Welcome to the forum. Yes, Stata can do this. The details of how depend on your data and what you want to do with it. For example:

    Code:
    egen mean_myvar = mean(myvar)
    Will make a new variable called -mean_myvar- and will place in it the mean of that variable, -myvar-, for every observation. There are other ways but are a little more advanced. For some more details, see:

    Code:
    help egen
    help summarize
    Since you have tagged multiple imputation in your post, I presume your end goal is to do mean imputation. Stata has a pretty convenient and powerful suite of tools for multiple imputation, and is worth reading in depth about. See -help mi intro substantive- and -help mi intro-.

    Comment


    • #3
      Hi ,

      I tried using this code even mean_myvar = mean(var1 va2r var3) but the function is apparently unknown .

      Just to clarify what I wanted to do: I have a set of different variables ( var1, var2 etc) with different means and I want to make a new variable that consists of the means of the different variables.

      Comment


      • #4
        Please help egen.
        Code:
        egen mean_myvar = rowmean(var1 va2r var3)
        Best regards.

        Raymond Zhang
        Stata 17.0,MP

        Comment


        • #5
          Thank you very much for the answer

          Comment

          Working...
          X