Stata 15 help for cf

[D] cf -- Compare two datasets

Syntax

cf varlist using filename [, all verbose]

Menu

Data > Data utilities > Compare two datasets

Description

cf compares varlist of the dataset in memory (the master dataset) with the corresponding variables in filename (the using dataset). cf returns nothing (that is, a return code of 0) if the specified variables are identical and a return code of 9 if there are any differences. Only the variable values are compared. Variable labels, value labels, notes, characteristics, etc., are not compared.

Options

all displays the result of the comparison for each variable in varlist. Unless all is specified, only the results of the variables that differ are displayed.

verbose gives a detailed listing, by variable, of each observation that differs.

Examples

Setup . sysuse auto . drop gear_ratio . replace mpg = 20 in 1/2 . replace rep78 = 6 in 3 . save mycf . sysuse auto

Compare the variables in memory with the variables in mycf.dta . cf _all using mycf

Same as above, but give a detailed listing of the differences . cf _all using mycf, verbose

Compare the mpg and foreign variables in memory with those variables in mycf.dta . cf mpg foreign using mycf

Same as above, but give a detailed listing of the differences . cf mpg foreign using mycf, verbose

Same as above, but list all specified variables, even if there are no differences . cf mpg foreign using mycf, verbose all

Stored results

cf stores the following in r():

Macros r(Nsum) number of differences


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