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: Combining strings by group
From
"Ben Hoen" <[email protected]>
To
<[email protected]>
Subject
st: Combining strings by group
Date
Tue, 15 Nov 2011 23:58:49 -0500
I can't seem to figure out how to concatenate strings for groups of
variables.
Assume I had the following dataset with two variables:
code type
1 a
1 c
2 e
3 f
3 g
3 z
I want to create a third (string) variable that concatenates the string
"type" by code group, which would produce the following output (the quotes
are to indicate a string variable):
code combinedtype
1 "a, c"
2 "e"
3 "f, g, z"
Therefore for each code group (1, 2 and 3), the type is concatenated with
commas separating each type.
Any ideas?
Ben Hoen
Principal Research Associate
Lawrence Berkeley National Laboratory
Office: 845-758-1896
Cell: 718-812-7589
[email protected]
http://eetd.lbl.gov/ea/emp/staff/hoen.html
*
* 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/