Statalist


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

Re: st: Comparing datasets


From   "Tim Wade" <[email protected]>
To   [email protected]
Subject   Re: st: Comparing datasets
Date   Tue, 16 Sep 2008 14:22:47 -0400

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
<[email protected]> 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 <[email protected]> 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
>>
>>
>> Biosketch: http://homepages.nyu.edu/~ray1/Biosketch2008.pdf
>>
>> CV:  http://homepages.nyu.edu/~ray1/vita.pdf
>>
>> ----- Original Message -----
>> From: Raphael Fraser <[email protected]>
>> Date: Monday, September 15, 2008 4:43 pm
>> Subject: st: Comparing datasets
>> To: [email protected]
>>
>>
>>> 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index