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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: AW: comparing strings


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: comparing strings
Date   Tue, 6 Jul 2010 18:00:38 +0200

<> 

You can -generate- an indicator variable to this effect, or -assert- the
relationship and see what happens. It may make sense to -trim()- the strings
to get rid of blanks beforehand.

*************
clear*
inp str15(name name1)
"John Smith" "Ray Adams"
"Jane Gore" "Jane Gore"
end

gen byte equalnames=name==name1
list, noo ab(15)

assert name==name1
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von
mt2235@columbia.edu
Gesendet: Dienstag, 6. Juli 2010 17:56
An: statalist@hsphsun2.harvard.edu
Betreff: st: comparing strings

Hi,

I have two variables name and name1 that contain strings. How can I  
compare whether the strings are the same or not?
For example in the same row  name can be "John Smith" and name1 can be  
"Ray Adams" so they are not the same. Or there can be another row that  
both name and name1 are "Jane Gore" so they are the same.


Thank you
Margie
*
*   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/


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