|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
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 <[email protected]>
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
<[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
*
* 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/