Bookmark and Share

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

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

st: Make categories from a list within a variable

From   Lynne Morgan <>
Subject   st: Make categories from a list within a variable
Date   Fri, 26 Oct 2012 11:52:37 -0500


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
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"


Lynne Morgan, MPH
Assistant Researcher
Survey of the Health of Wisconsin
University of Wisconsin, Madison
(p) 608-821-1243

*   For searches and help try:

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