Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Top 10 Tricks in Stata (summary to date)

From   "Nick Cox" <>
To   <>
Subject   st: Top 10 Tricks in Stata (summary to date)
Date   Sun, 23 May 2004 18:32:18 +0100

On Friday 21 May 2004 I asked

Which would we nominate as (say) the top ten tricks which are the
deepest and most Stataish features in what we use? What is _both_
simple _and_ deep?  What leads to great results with at most a few
lines of code? 


I'd nominate straight away 

1. -by:-. 

2. -foreach- or -forval- with varlists or numlists. 

3. -merge-. I rarely use it but -merge-masters have real leverage
in file manipulations. 

4. -assert-. My candidate for the most underestimated command in
Stata (second is -count-).  

5. -reshape-. 

Any other nominations? 



Here is a compilation of responses, edited a bit. I omitted some 
very general comments and the most facetious suggestions.  I don't
think everyone was playing exactly the same game, not that it

Thanks to 
Judith Abrams, Alan Acock, Renzo Comolli, Rafa De Hoyos, 
Adrian de la Garza, Peter Jepsen, SamL, Arnold Levinson. 
Clive Nicholas, Bill Rising, Amani Siyam, Antoine Terracol, 
Clint Thompson, John Wallace, Richard Williams, Fred Wolfe


-assert- (Judith Abrams, Clint Thompson) 

-by:- (Bill Rising, Antoine Terracol)

-char- (Renzo Comolli, Bill Rising) 

-collapse- (Amani Siyam)

-collin- (very generous amounts of well-organised output) (Clive

-compress- (Bill Rising) 

-destring- (Rafa De Hoyos) 

-egen- (Amani Siyam, Antoine Terracol)

-encode- (Clint Thompson) 
-encode- gets you a lot of bang for the buck: conversion of a
string variable into a numeric with simultaneous labeling of the
values with the original string information (John Wallace) 

-est table- (Clive Nicholas) 

comparing Stata to the competition the most useful command for me
is -findit- (Alan Acock) 

-for- (especially the old one) (Judith Abrams) 
-for*- (-foreach- etc.) (Bill Rising) 

-generate- (Clive Nicholas) 

-insheet- (Clive Nicholas) 

-lexis- (Amani Siyam) 

macrolist, macros (Fred Wolfe) 

-margin- (very fast) (Clive Nicholas) 

-matrix score- (Rafa De Hoyos) 

-outreg- (very versatile) (Clive Nicholas) 

I very much like -predict-.  I especially like that it can be run
on something other than the estimation sample.  Indeed, I
sometimes temporarily wipe out the "real" data, type in some
hypothetical values, run -predict-, and then restore the original
data.  This can be quite useful for making things like logistic
regression more tangible, where it is hard to see what impact
variables actually have. I also like -adjust- for similar reasons. 
(Richard Williams)

-recode- (Bill Rising) 

the versatile options of -regress-, particularly -beta- and -hc3-
(Clive Nicholas) 

-reshape- (Renzo Comolli, Amani Siyam) 
The fact that you can easily swap between long and wide data
formats once it has been run is especially convenient, and
unexpectedly useful for a lot of what I do. (John Wallace) 

-return list-. Or rather, all the good things stored in r().
(Peter Jepsen) 

-set memory-, for its optimisation in the use of resources (Rafa
De Hoyos) 

-ssc install- (Clive Nicholas) 

-statsby- is my new favourite command.  I almost never use
-collapse- since I discovered how to use -statsby-. (John Wallace) 

-stset- (Peter Jepsen, Bill Rising)

-sum()- (Fred Wolfe) 

the -svy- commands (Rafa De Hoyos) 
For working with complex-sample survey data (as I do all the
time), the -svy- suite is Top 10 for simple syntax, flexibility
(especially now that the -subpop()- option accepts -if- statements),
comprehensive output and the same post-estimation approaches used
for non-survey estimation programs. (Arnold Levinson) 

-syntax- (Bill Rising) 

I also very much like the -test- command and its variations.
(Richard Williams) 

-tabulate-, particularly with use of the -all- option (Clive

I still use -tokenize- a lot. (Antoine Terracol)

-update- (Bill Rising) 
-update- because, with one word (i.e., simple) it allows users to
easily and quickly stay abreast of the latest developments, and
thus is a fundamental (i.e., deep) aspect of the continued
evolution of all the other commands. (SamL)

-xi:- (Clive Nicholas) 

_n & _N (Peter Jepsen, Antoine Terracol) 

all the string functions: -substr(), -trim()-, -length()-, etc. 
(Adrian de la Garza)

treating true as 1 and false as 0 (Bill Rising) 

some of Scott Long's extensions for limited dependent variables
have to be included as well (Alan Acock) 


> -----Original Message-----
> From:
> []On Behalf Of Alan Acock
> Sent: 23 May 2004 00:12
> To:
> Subject: st: Top 10 Tricks in Stata
> Maybe it is too obvious but comparing Stata to the 
> competition the most
> useful command for me is
> findit xxxx
> Some of Long's extensions for limited dependent variables have to be
> included as well
> Alan Acock
> *
> *   For searches and help try:
> *
> *
> *

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index