Announcement

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

  • Do you have a favorite command or feature in Stata?

    Dear Stata users,

    About 7 years ago, StataCorp officially had a contest in Facebook that let contestants post their favorite command or features in Stata. I really learn some new command from that post, and I hope you can share your favorite command here. I believe that your reply will lead us to discovery of the new world. Thank you.
    https://blog.stata.com/2012/03/19/ou...rite-commands/
    Last edited by Chen Samulsion; 06 Mar 2019, 17:43.

  • #2
    I'm liking Ben Jann's user written command grstyle at the moment, for example:

    Code:
    set scheme s2color
    grstyle init
    grstyle set imesh, horizontal
    grstyle set color, opacity(50): p#markfill
    grstyle set color, opacity(50): p#markline

    Comment


    • #3
      This is a bit niche, but I'm very partial to the Stata Plugin Interface: https://www.stata.com/plugins

      It underlies several packages I've written for Stata, and it's lead to many a boost in productivity when using it.

      Comment


      • #4

        mata. Data management commands; assert, confirm, isid, datasignature, char.

        sysprofile.do always include:
        Code:
        set varabbrev off

        Comment


        • #5
          Hi Bjarte Aagnes, thanks for sharing. Variable abbreviations can help us to save typing time, why you prefer turning it off?

          Comment


          • #6
            Variable abbreviations can easily lead to bugs in your scripts: Say you have two variables in your dataset ed and educ, and you forgot that ed was in your dataset. If you typed ed with the expectation that it is an abbreviation of educ, then you can expect some really unexpected outcomes... If you rely on variable abbreviations then you probably should use shorter variable names.

            Having said that, I tend to leave variable abbreviations on.
            ---------------------------------
            Maarten L. Buis
            University of Konstanz
            Department of history and sociology
            box 40
            78457 Konstanz
            Germany
            http://www.maartenbuis.nl
            ---------------------------------

            Comment


            • #7
              I turn varabbrev off because variables and scalars share name space and variables have presedence: With -varabbrev on- refering to a scalar name might return the value of the first observation of an abbreviated variable name. This behaviour can lead to errors which can be very difficult to catch. (Using tempname to name scalars, or using the scalar() function reduce the risk, but not all programs follow this practice). To illustrate:
              Code:
              sysuse auto
              set varabbrev on
              scalar w = c(pi)
              scalar r = 2 * w /* with -varabbrev on- w == weight[1] */
              capture noi assert scalar(r) == 2 * c(pi)
              di r
              di rep78[1]
              scalar dir
              Code:
              . capture noi assert scalar(r) == 2 * c(pi)
              assertion is false
              
              . di r
              3
              
              . di rep78[1]
              3
              
              . scalar dir
                       r =       5860
                       w =  3.1415927

              Comment


              • #8
                I nominate help, and its sibling search, not only for their content but also their links. (Much under-used commands too!) ssc is pretty dandy as well.

                BTW I strongly second Bjarte's recommendation to set varabbrev off. Absolutely essential if you do any serious data management work.

                Comment


                • #9
                  The others' suggestions are spot on. To them I might add:

                  margins (game-changing in applied microeconometrics)

                  contract (hugely helpful when dealing with large samples)

                  Mata (still amazed how many Stata-using colleagues and students do not even know about Mata, much less use it)

                  Comment


                  • #10
                    I would like to recommend some nice community-contributed commands for doing data management.
                    Including -renvars-, -labvars-, -labutil- and especially -labvarch-, -labutil2- and especially -labdeval- & -labvalch3-, -sencode-, -sxpose-, -htmlcb-, -fsum-, -tab_chi- and especially -tabm-, -estout-, -ascii2unicode-, and etc.

                    Comment

                    Working...
                    X