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]

Re: st: Make categories from a list within a variable


From   daniel klein <klein.daniel.81@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Make categories from a list within a variable
Date   Fri, 26 Oct 2012 19:26:03 +0200

Lynne,

this might help you get started

Herrin, Jeph, Poen, Eva (2008). Stata tip 64: Cleaning up user-entered
string variables. The Stata Journal, 8(3): 444-445.

The article is available
here:http://www.stata-journal.com/sjpdf.html?articlenum=dm0039

Also see -help string functions-

Best
Daniel

--
Hello,


I have a variable that asks about country of origin. Unfortunately, my
data entry people were not consistent, so I ended up with things like
this:

1    german
2    french, german, spanish
3    FRENCH GERMAN
4    finnish,irish,english,french,german, bohemian
5     polish and german
6    swedish & east european


How can I search this variable and create an indicator variable for
each ethnicity based on the string? Can I search within the string to
find a keyword?

*What is the proper lingo for the bolded text?

gen german = 0
replace german = 1 if coorigin contains "german"


Thanks!!
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index