Announcement

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

  • Standardization of variable

    Hi, everyone. I have a problem when standardizing a variable into z-score in stata.

    summarize x
    generate x_s= (x- r(mean))/r(std)

    The following commands used to work but now it doesn't. I wonder why it does not work to standardize the variable. Is the local macro problem? I don't want to use egen to generate. Thanks a lot.

  • #2
    Welcome to the forum! Please read the FAQ to increase your chance to get answers.
    Is the local macro problem?
    We can't tell much if you just type what you enter without what type of error Stata gave you back. I see two points here: first, local macro will run if you execute the commands together and not line by line. Second, type return list after summarize to get the exact name of the scalars. It should be r(sd) not r(std).

    Comment


    • #3
      Welcome to the Stata Forum / Statalist.

      Try it with -sd - instead of - std -.

      Edit: crossed with Oded's reply.
      Best regards,

      Marcos

      Comment


      • #4
        Really thanks for the help. It is solved now.

        Comment

        Working...
        X