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

From |
Austin Nichols <austinnichols@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: compare files, vars only |

Date |
Thu, 19 Feb 2009 11:20:28 -0500 |

David Kantor <kantor.d@att.net>: No, but see -vlc- on SSC. To compare sets of variables, you could just prog cvar, rclass qui use in 1 using `"`1'"' unab f: _all qui use in 1 using `"`2"' unab g: _all loc i: list f & g di as txt `"In `1'"' _n as res "`f'" di as txt `"In `2'"' _n as res "`g'" di as txt "In both" _n as res "`i'" if "`i'"=="" di as err "No variables in common" return local file1 `"`1'"' return local vars1 `f' return local file2 `"`2'"' return local vars2 `g' return local both `i' end cvar "`c(sysdir_base)'n/nlsw88" "`c(sysdir_base)'a/auto" Or did you want to compare an arbitrary number of files? Also easy with -mac shift- : prog cvars, rclass loc n=1 while `"`1'"'!="" { qui use in 1 using `"`1'"' unab f`n': _all di as txt `"In `1'"' _n as res "`f`n''" return local file`n' `"`1'"' 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 "`i'"=="" di as err "No variables in common" return local all "`f'" end cvars "`c(sysdir_base)'n/nlsw88" "`c(sysdir_base)'a/auto" "`c(sysdir_base)'a/auto" On Thu, Feb 19, 2009 at 10:41 AM, David Kantor <kantor.d@att.net> wrote: > Hi. > Does anyone know of a program to compare the sets of variables in two data > files? What I have in mind is something akin to -cf-, but... > it would not compare values -- only the names of variables; > it would not care whether the two data files had the same number of > observations. > > I was planning to write such a program, but I wanted to be sure that it > hadn't already been done. > Thanks > --David * * 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/

**Follow-Ups**:**Re: st: compare files, vars only***From:*Austin Nichols <austinnichols@gmail.com>

**References**:**st: compare files, vars only***From:*David Kantor <kantor.d@att.net>

- Prev by Date:
**Re: st: AW: compare files, vars only** - Next by Date:
**AW: st: AW: compare files, vars only** - Previous by thread:
**Re: st: AW: compare files, vars only** - Next by thread:
**Re: st: compare files, vars only** - Index(es):

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