help for obsdiff

Identify differences in values across observations for a variable.

obsdiff varlist [if exp] [using newfile] [ , rows(numlist) replace all ]


obsdiff lists the differences among observations/records in a varlist. This program is particularly useful for data where observations are near duplicates and you need to identify the variables that differ. In this way, obsdiff operates similar to duplicates list except that it lists differences (not duplicates) for the varlist in the range of observations/records specified in the option rows. The output can be saved to a text file with the using option.


rows(numlist) required unless all is specified. This option identifies the range of rows or observations that should be examined for differences for each variable in the varlist. The format for the numlist is explained in numlist.

replace overwrites newfile.txt, if it exists.

all is used in place of the range option to indicate that all observations should be examined for differences among the variables in the varlist. Same as specifying rows(1/`=_N').

if is allowed.

`r(diff_vars)' contains a list of variables in varlist with differences in the specified rows.


. sysuse auto, clear . obsdiff make for rep78 , r(8/12) . di "`r(diff_vars)'"

. obsdiff for rep78, all . obsdiff rep78 if for==0, r(1/10) . obsdiff rep78 if for==1 using "obsdiff_log", all replace


Eric A. Booth, Texas A&M University ebooth@ppri.tamu.edu http://www.eric-a-booth.com

Also see

On-line: help for list; duplicates list; unique(if installed)