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]

st: AW: comparing strings


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
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: [email protected]
[mailto:[email protected]] Im Auftrag von
[email protected]
Gesendet: Dienstag, 6. Juli 2010 17:56
An: [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index