Announcement

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

  • Standardize variables with designated mean and SD

    Hi, I have a standardized variable in my data, but the standardized variable is hard to interpret (see a summary in the picture). I want to re-standardize this variable by a designated mean of 50 and standard deviation of 10 by using the egen command. But the STATA (14.2) shows the following errors, could anyone help me out? Thanks!
    Click image for larger version

Name:	WX20181028-171042@2x.png
Views:	1
Size:	25.7 KB
ID:	1467908

    The STATA output:
    Code:
    . egen stdscore=std(cog3pl) [, mean(50) std(10)]
    weights not allowed
    r(101);
    The data

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float cog3pl
      .128507
     1.235879
      .083937
     -.522185
      .036172
      .247188
     1.119603
      .938166
     -.944188
      1.12942
      .504442
     -.636827
      .599695
     1.227446
      .364622
     1.543919
      .508021
       .62899
      .421879
     -.146026
       .58851
     -.291137
      .878521
      .058442
      .468513
     1.466815
     1.350555
      .852585
     -.355217
      .757817
     -.042532
      .580181
     1.211923
     -.498497
     1.066475
      .633334
      .980748
      .414249
     1.007716
      .967812
      .348596
     -.146026
     -.182904
     1.525641
      .836506
      .264453
     -.710774
      .411819
      .836878
      .090278
     -.335539
     -.097986
     1.211923
      .331569
    -1.101023
     1.456134
     1.198598
     1.621865
      .822771
      .209975
     1.045911
      .036848
      .713518
     1.212803
      .704509
    -1.803628
      .322971
     -.158247
      .959742
     1.033147
     -.049032
     1.059551
       .79829
      .938166
     -.783733
      .200613
     1.349313
     1.383719
      .860087
      .536033
      .483642
     1.043612
      .295511
     1.460538
      .067473
      .378723
       .54301
     1.235068
     1.067553
     -.275182
      .329491
      1.38978
      .847831
     1.474833
     1.652636
     1.211923
     1.205036
     1.350555
     -.125119
     -.403901
    end

  • #2
    Remove the square brackets. You copied them from the syntax diagram, but they indicate optional elements in the syntax and are not meant to be typed in your command.

    Comment


    • #3
      Originally posted by Nick Cox View Post
      Remove the square brackets. You copied them from the syntax diagram, but they indicate optional elements in the syntax and are not meant to be typed in your command.
      Oh I see. Thank you so much!

      Comment

      Working...
      X