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   Thu, 18 Sep 2008 09:57:02 -0700

Thank you! By preceding the code with
	-version 9-
then the program written by Tim Wade works just fine.
Michael


Hi,
Just type

version 9
code follows here
.....
...

Cheers
rajesh


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Michael McCulloch
Sent: 18 September 2008 17:36
To: statalist@hsphsun2.harvard.edu
Subject: RE: st: Comparing datasets

Sorry Rajesh, I don't know what is meant by putting v9 on top of the
do file! Michael

Hi,
Did you try putting version 9 on top of the do file and running it? it did
not work for me on version 9 when I ran it as is. However, it did when I
put
version 9 on top of the do file.
Hth
rajesh

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Steven Samuels
Sent: 18 September 2008 15:28
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: Comparing datasets


I haven't been following this thread, but in the past I had troubles
after running statements like:

tempfile t1
save `t1', replace

Technical support told me that "replace" should not be used when
saving temporary files.

-Steve

On Sep 18, 2008, at 10:11 AM, Tim Wade wrote:

  I'm not sure what the problem is, I tested this example in Stata 9.2,
  and it seems to work there, as does this improved example based on
  posts by David and Eva:


  sysuse auto.dta, clear
  tempfile auto
  save "`auto'", replace
  clear

  sysuse auto.dta, clear
  drop make
  tempfile auto2
  save "`auto2'", replace
  clear

  desc using "`auto'", varlist
  local x `r(varlist)'

  desc using "`auto2'", varlist
  local x2 `r(varlist)'


  local diff2: list x - x2
   di "`diff2'"



  On Tue, Sep 16, 2008 at 5:01 PM, Michael McCulloch <mm@pinest.org>
  wrote:
  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/

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

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