Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: comparing datasets

From   Maarten Buis <>
Subject   Re: st: comparing datasets
Date   Mon, 8 Aug 2011 17:15:47 +0200

--- On Mon, Aug 8, 2011 at 4:45 PM, Mauro Mastrogiacomo wrote:
>> one way could be
>> des, varlist
>> local myvars=r(varlist)
>> dis "`myvars'"
>> if you repeat this also for the second dataset then you can subtract the two macro's and the difference is what you need.

--- On Mon, Aug 8, 2011 at 5:02 PM, Abhimanyu Arora wrote:
> I see, Mauro, thanks, that's an ingenious way, but could you please
> elaborate on "differencing two macros"?

You need to look for extended macro functions, in particular the
facilities for handling lists. You can find the help files by Typing
in Stata -help macro-, and click on the link extended macro functions.

*------------- begin example ---------------
// file one
sysuse auto, clear
local file1 "`r(varlist)'"

// file 2
drop mpg turn
local file2 "`r(varlist)'"

// difference
local diff : list file1 - file2
di "`diff'"
*------------ end example ----------------
(For more on examples I sent to the Statalist see: )

Hope this helps,

Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index