Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: Comparing datasets


From   Michael McCulloch <mm@pinest.org>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: Comparing datasets
Date   Tue, 16 Sep 2008 17:12:49 -0700

This looks very useful. If I run the example and neither dropped variable are reported by the program, what does that mean? I'm using v9.2.


If you use -cf- you have to use it in both directions, to be on the
safe side. However, -cf- compares all values as well, which will
clutter the output considerably if these are actually two different
datasets with the same variable names.

Here is a way to avoid this problem. The example uses the auto data.

****
sysuse auto, clear
drop foreign
save myauto1
sysuse auto, clear
drop price head
save myauto2

qui ds
local second `r(varlist)'

use myauto1, clear
qui ds
local first `r(varlist)'

foreach x of local first {
 if strpos("`second'","`x'") == 0 {
   di in yellow "`x' is not present in the second file."
 }
}

foreach x of local second {
 if strpos("`first'","`x'") == 0 {
   di in yello "`x' is not present in the first file."
 }
}

erase myauto1.dta
erase myauto2.dta
************************

Eva

2008/9/15 Martin Weiss <mw.stlist@googlemail.com>:
 > -h cf-
 >
 Martin Weiss
 _______________________
 ----- Original Message ----- From: "Raphael Fraser"
 <raphael.fraser@gmail.com>
 To: <statalist@hsphsun2.harvard.edu>
 Sent: Monday, September 15, 2008 10:42 PM
 Subject: st: Comparing datasets


 I have 300 variables in one dataset, 298 in another dataset. Both
 datasets should have the same variable names. How can I identify which
 variables do not match up?

 Raphael
 *
 *   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/
 *
 *   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/

*
*   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/
*
*   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   |   What's new   |   Site index