Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Compare two files by record id variable if data sets have different record counts


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Compare two files by record id variable if data sets have different record counts
Date   Tue, 17 Apr 2012 22:20:11 +0100

Why not just -merge- and then compare what you get?

Note that the author of -cf3-, Thomas Steichen, is very firmly retired
from Stata activity.

Nick

On Tue, Apr 17, 2012 at 10:03 PM, Jeremy Page <miahpage@gmail.com> wrote:

> I would like to compare record level data from two datasets that have
> different record counts using an id variable to link the two files.
>
> The user written command -cf3- (ssc install cf3) will compare two
> datasets and list the records that have conflicting information but
> the program will break after the command if the number of records in
> the two datasets is different. I have included an example below using
> auto.dta that shows the code breaking. I would like to be able to
> continue programming even if the number of records is different
> between the two files.
>
> Is there a command that will allow me to compare records across
> datasets using a record id that will not break if the sample sizes are
> different?
>
> I am using Stata 11.2 on Windows 7.
>
> Best,
> Jeremy
>
>
> *******Begin Example*********
> ssc install cf3
>
> webuse auto,clear
> gen id = _n
> drop if foreign == 1
> tempfile noforeign
> save `noforeign'
>
> webuse auto,clear
> gen id = _n
> cf3 _all using `noforeign', id(id) noverbose
>
> display "This line will not print."
> ******End Example*************

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index