On Mon, Feb 25, 2013 at 7:15 AM, James Bernard wrote:
> I have a variable ("Technology) that indicates type(s) of a technology
> for each record. I want to aggregate the unique values of this
> variable under one new variable
*---------------- begin example ----------------
// create example data
clear all
input str23 type
"Monoclonals"
"Vaccines"
"Adjuvant, Vaccine"
"Combinchem, Monoclonals"
end
// put each type in a separate variable
split type, p(", ")
// original variable is no longer needed
drop type
// reshape such that the types are stacked
gen id = _n
reshape long type, i(id) j(order)
// id and order are no longer needed
drop id order
// remove missing values
drop if type == ""
// remove duplicates
bys type : keep if _n == 1
// see the results
list
*----------------- end example -----------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )
Hope this helps,
Maarten
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany
http://www.maartenbuis.nl
---------------------------------
*
* 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/