Statalist


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

Re: st: Comparing datasets


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

Hi Tim,
Is your example for Stata 10? When I try to reproduce your nifty example, I get:
. save "`auto2'", replace
invalid file specification
r(198);

Michael



There is probably a more elegant solution to this, but saving the
variable names in a local macro and comparing the macro lists might
work, e.g., :


. sysuse auto.dta, clear
(1978 Automobile Data)

. preserve

. drop make

. tempfile auto2

. save "`auto2'", replace
file C:\DOCUME~1\twade\LOCALS~1\Temp\ST_00000005.tmp saved

. restore

.
. local x

. foreach var of varlist _all {
2. local x "`x' " "`var'"
3. }

. di "`x'"
make price mpg rep78 headroom trunk weight length turn displacement
gear_ratio foreign

.
. clear

. use `auto2'
(1978 Automobile Data)

.
. local x2

. foreach var of varlist _all {
2. local x2 "`x2' " "`var'"
3. }

.
.
. local diff2: list x - x2

. di "`diff2'"
make

.
end of do-file

. Hope this helps, TIm



On Tue, Sep 16, 2008 at 1:22 PM, Raphael Fraser
<raphael.fraser@gmail.com> wrote:
> Robert,
>
> The problem with cf2 & cf3 is that, they compare the variable VALUES.
> I intend to append the data and just want to ensure that the variable
> NAMES match and not the variable values.
>
> At present -append- offers no way to check this.
>
> Raphael
>
> On Tue, Sep 16, 2008 at 3:35 AM, Robert A Yaffee <bob.yaffee@nyu.edu> wrote:
>> Raphael,
>> Check out the compare cf2 and cf3 commands. The latter two can be found on the SSC archive.
>> Regards,
>> Robert
>>
>> Robert A. Yaffee, Ph.D.
>> Research Professor
>> Silver School of Social Work
>> New York University
*
*   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