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

Re: st: AW: compare files, vars only

From   Austin Nichols <>
Subject   Re: st: AW: compare files, vars only
Date   Thu, 19 Feb 2009 12:10:22 -0500

Johannes Geyer <>:
OK--I see now.  Try this on for size:

cap prog drop cvars
prog cvars, rclass
 loc n=1
 while `"`1'"'!="" {
 if `"`1'"'=="." {
  loc u
  loc c=cond(c(changed)," (changed version in memory)","")
  loc 1 `"`c(filename)'"'
 else {
  loc c
  loc u `"using `"`1'"'"'
 qui _describe `u', varlist
 loc f`n' `"`r(varlist)'"'
 di as txt `"In `1' "' as err "`c'" _n as res "`f`n''"
 return local file`n' `"`1'`c'"'
 return local vars`n' `f`n''
 if `n'==2 loc f: list f1 & f2
 else loc f: list f & f`n'
 loc n=`n'+1
 mac sh
 di as txt "In all files" _n as res "`f'"
 if "`f'"=="" di as err "No variables in common"
 return local all "`f'"

sysuse auto, clear
drop  gear_ratio displacement
tempfile new
save `new'
sysuse auto, clear
drop mpg
cvars . `new'
cvars . `new'  "`c(sysdir_base)'a/auto"
*   For searches and help try:

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