Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: comparing contents of two columns (variables)


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: comparing contents of two columns (variables)
Date   Sun, 14 Apr 2013 11:44:50 +0100

For "columns" read "variables". It's always a good idea to use Stata
terminology on Statalist, and not to presume we're spreadsheet users
on vacation.

-cf3- (not -CF3-; I don't think there is any such command) is highly accessible.

. findit cf3

will show you where it is. But it's for comparing datasets, and you
want to compare variables.

levelsof A, local(Avals)
levelsof B, local(Bvals)

followed by commands detailed at -help macrolists- should help.

If you have an enormous number of distinct values, this won't work but
reasons documented at -help levelsof-.

Nick
[email protected]


On 14 April 2013 10:31, James Bernard <[email protected]> wrote:

> I was wondering if you know of any command in stata that can compare
> contents of two columns. Imagive I have two columns
>
>   A                 B
> -------           ---------
>
> 304             112
> 203             123
> 776             304
> 334             555
> 212             111
> 111             444
> 123             999
> 200
> 300
> 277
>
> Now I want to count how many of the contents of column B cannot be
> found in column A (which is 5 out of 7)
>
> I looked up the web and found that someone talked about a command
> called CF3, but I could not get anything more about this command.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index