4th Edition

# Stata Tips, Fourth Edition, Volume I: Tips 1-119

*Stata Tips* provides concise and insightful notes about commands, features, and tricks that will help you obtain a deeper understanding of Stata.

The book comprises the contributions of the Stata community that have appeared in the Stata Journal since 2003. Each tip is a brief article that provides practical advice on using Stata. With tips covering a breadth of topics in statistics, graphics, data management, and programming, both new and experienced Stata users are sure to find tips that will be useful in their research.

Introducing Stata tips

Stata tip 1: The eform() option of regress

R. Newson

Stata tip 2: Building with floors and ceilings

N. J. Cox

Stata tip 3: How to be assertive

W. Gould

Stata tip 4: Using display as an online calculator

P. Ryan

Stata tip 5: Ensuring programs preserve dataset order

R. Newson

Stata tip 6: Inserting awkward characters in the plot

N. J. Cox

Stata tip 7: Copying and pasting under Windows

S. Driver and P. Royston

Stata tip 8: Splitting time-span records with categorical time-varying covariates

B. Jann

Stata tip 9: Following special sequences

N. J. Cox

Stata tip 10: Fine control of axis title positions

P. Ryan and N. Winter

Stata tip 11: The nolog option with maximum-likelihood modeling commands

P. Royston

Stata tip 12: Tuning the plot region aspect ratio

N. J. Cox

Stata tip 13: generate and replace use the current sort order

R. Newson

Stata tip 14: Using value labels in expressions

K. Higbee

Stata tip 15: Function graphs on the fly

N. J. Cox

Stata tip 16: Using input to generate variables

U. Kohler

Stata tip 17: Filling in the gaps

N. J. Cox

Stata tip 18: Making keys functional

S. Driver

Stata tip 19: A way to leaner

faster graphs

P. Royston

Stata tip 20: Generating histogram bin variables

D. A. Harrison

Stata tip 21: The arrows of outrageous fortune

N. J. Cox

Stata tip 22: Variable name abbreviation

P. Ryan

Stata tip 23: Regaining control over axis ranges

N. Winter

Stata tip 24: Axis labels on two or more levels

N. J. Cox

Stata tip 25: Sequence index plots

U. Kohler and C. Brzinsky-Fay

Stata tip 26: Maximizing compatibility between Macintosh and Windows

M. S. Hanson

Stata tip 27: Classifying data points on scatter plots

N. J. Cox

Stata tip 28: Precise control of dataset sort order

P. Schumm

Stata tip 29: For all times and all places

C. H. Franklin

Stata tip 30: May the source be with you

N. J. Cox

Stata tip 31: Scalar or variable? The problem of ambiguous names

G. I. Kolev

Stata tip 32: Do not stop

S. P. Jenkins

Stata tip 33: Sweet sixteen: Hexadecimal formats and precision problems

N. J. Cox

Stata tip 34: Tabulation by listing

D. A. Harrison

Stata tip 35: Detecting whether data have changed

W. Gould

Stata tip 36: Which observations?

N. J. Cox

Stata tip 37: And the last shall be first

C. F. Baum

Stata tip 38: Testing for groupwise heteroskedasticity

C. F. Baum

Stata tip 39: In a list or out? In a range or out?

N. J. Cox

Stata tip 40: Taking care of business

C. F. Baum

Stata tip 41: Monitoring loop iterations

D. A. Harrison

Stata tip 42: The overlay problem: Offset for clarity

J. Cui

Stata tip 43: Remainders

selections

sequences

extractions: Uses of the modulus

N. J. Cox

Stata tip 44: Get a handle on your sample

B. Jann

Stata tip 45: Getting those data into shape

C. F. Baum and N. J. Cox

Stata tip 46: Step we gaily

on we go

R. Williams

Stata tip 47: Quantile–quantile plots without programming

N. J. Cox

Stata tip 48: Discrete uses for uniform()

M. L. Buis

Stata tip 49: Range frame plots

S. Merryman

Stata tip 50: Efficient use of summarize

N. J. Cox

Stata tip 51: Events in intervals

N. J. Cox

Stata tip 52: Generating composite categorical variables

N. J. Cox

Stata tip 53: Where did my p-values go?

M. L. Buis

Stata tip 54: Post your results

P. Van Kerm

Stata tip 55: Better axis labeling for time points and time intervals

N. J. Cox

Stata tip 56: Writing parameterized text files

R. Gini

Stata tip 57: How to reinstall Stata

W. Gould

Stata tip 58: nl is not just for nonlinear models

B. P. Poi

Stata tip 59: Plotting on any transformed scale

N. J. Cox

Stata tip 60: Making fast and easy changes to files with filefilter

A. R. Riley

Stata tip 61: Decimal commas in results output and data input

N. J. Cox

Stata tip 62: Plotting on reversed scales

N. J. Cox and N. L. M. Barlow

Stata tip 63: Modeling proportions

C. F. Baum

Stata tip 64: Cleaning up user-entered string variables

J. Herrin and E. Poen

Stata tip 65: Beware the backstabbing backslash

N. J. Cox

Stata tip 66: ds—A hidden gem

M. Weiss

Stata tip 67: J() now has greater replicating powers

N. J. Cox

Stata tip 68: Week assumptions

N. J. Cox

Stata tip 69: Producing log files based on successful interactive commands

A. R. Riley

Stata tip 70: Beware the evaluating equal sign

N. J. Cox

Stata tip 71: The problem of split identity

or how to group dyads

N. J. Cox

Stata tip 72: Using the Graph Recorder to create a pseudograph scheme

K. Crow

Stata tip 73: append with care!

C. F. Baum

Stata tip 74: firstonly

a new option for tab2

R. G. Gutierrez and P. A. Lachenbruch

Stata tip 75: Setting up Stata for a presentation

K. Crow

Stata tip 76: Separating seasonal time series

N. J. Cox

Stata tip 77: (Re)using macros in multiple do-files

J. Herrin

Stata tip 78: Going gray gracefully: Highlighting subsets and downplaying substrates

N. J. Cox

Stata tip 79: Optional arguments to options

N. J. Cox

Stata tip 80: Constructing a group variable with specified group sizes

M. Weiss

Stata tip 81: A table of graphs

M. L. Buis and M. Weiss

Stata tip 82: Grounds for grids on graphs

N. J. Cox

Stata tip 83: Merging multilingual datasets

D. L. Golbe

Stata tip 84: Summing missings

N. J. Cox

Stata tip 85: Looping over nonintegers

N. J. Cox

Stata tip 86: The missing() function

B. Rising

Stata tip 87: Interpretation of interactions in nonlinear models

M. L. Buis

Stata tip 88: Efficiently evaluating elastics with the margins command

C. F. Baum

Stata tip 89: Estimating means and percentiles following multiple imputation

P. A. Lachenbruch

Stata tip 90: Displaying partial results

M. Weiss

Stata tip 91: Putting unabbreviated varlists into local macros

N. J. Cox

Stata tip 92: Manual implementation of permutations and bootstraps

L. Ãngquist

Stata tip 93: Handling multiple y axes on twoway graphs

V. Wiggins

Stata tip 94: Manipulation of prediction parameters for parametric survival regression models

T. Boswell and R. G. Gutierrez

Stata tip 95: Estimation of error covariances in a linear model

N. J. Horton

Stata tip 96: Cube roots

N. J. Cox

Stata tip 97: Getting at ρ's and σ's

M. L. Buis

Stata tip 98: Counting substrings within strings

N. J. Cox

Stata tip 99: Taking extra care with encode

C. Schechter

Stata tip 100: Mata and the case of the missing macros

W. Gould and N. J. Cox

Stata tip 101: Previous but different

N. J. Cox

Stata tip 102: Highlighting specific bars

N. J. Cox

Stata tip 103: Expressing confidence with gradations

U. Kohler and S. Eckman

Stata tip 104: Added text and title options

N. J. Cox

Stata tip 105: Daily dates with missing days

S. J. Samuels and N. J. Cox

Stata tip 106: With or without reference

M. L. Buis

Stata tip 107: The baseline is now reported

M. L. Buis

Stata tip 108: On adding and constraining

M. L. Buis

Stata tip 109: How to combine variables with missing values

P. A. Lachenbruch

Stata tip 110: How to get the optimal k-means cluster solution

A. Makles

Stata tip 111: More on working with weeks

N. J. Cox

Stata tip 112: Where did my p-values go? (Part 2)

M. L. Buis

Stata tip 113: Changing a variable's format: What it does and does not mean

N. J. Cox

Stata tip 114: Expand paired dates to pairs of dates

N. J. Cox

Stata tip 115: How to properly estimate the multinomial probit model with heteroskedastic errors

M. Herrmann

Stata tip 116: Where did my p-values go? (Part 3)

M. L. Buis

Stata tip 117: graph combine—Combining graphs

L. Ãngquist

Stata tip 118: Orthogonalizing powered and product terms using residual centering

C. Sauer

Stata tip 119: Expanding datasets for graphical ends

N. J. Cox

### Biography

**Nicholas Cox** is a statistically minded geographer at Durham University. He contributes talks, postings, FAQ, and programs to the Stata user community. He has also coauthored 16 commands in official Stata. He was an author of several inserts in the Stata Technical Bulletin and is Editor-at-Large of the Stata Journal.